mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 06:27:59 +01:00
#86: More Postgres tweaks
This commit is contained in:
parent
ab127a0c72
commit
4b0ed2fd1b
7 changed files with 20 additions and 22 deletions
|
@ -49,7 +49,7 @@ class ToggleFavouriteCommand extends CommandBase
|
||||||
|
|
||||||
return $user != null;
|
return $user != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getEntityBeingFavourited():Favouritable
|
private function getEntityBeingFavourited():Favouritable
|
||||||
{
|
{
|
||||||
switch ($this->_resourceType) {
|
switch ($this->_resourceType) {
|
||||||
|
@ -80,10 +80,9 @@ class ToggleFavouriteCommand extends CommandBase
|
||||||
$fav = new Favourite();
|
$fav = new Favourite();
|
||||||
$fav->$typeId = $this->_resourceId;
|
$fav->$typeId = $this->_resourceId;
|
||||||
$fav->user_id = Auth::user()->id;
|
$fav->user_id = Auth::user()->id;
|
||||||
$fav->created_at = time();
|
|
||||||
$fav->save();
|
$fav->save();
|
||||||
$isFavourited = true;
|
$isFavourited = true;
|
||||||
|
|
||||||
Notification::newFavourite($this->getEntityBeingFavourited(), $fav->user);
|
Notification::newFavourite($this->getEntityBeingFavourited(), $fav->user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,10 +62,9 @@ class ToggleFollowingCommand extends CommandBase
|
||||||
$follow = new Follower();
|
$follow = new Follower();
|
||||||
$follow->$typeId = $this->_resourceId;
|
$follow->$typeId = $this->_resourceId;
|
||||||
$follow->user_id = Auth::user()->id;
|
$follow->user_id = Auth::user()->id;
|
||||||
$follow->created_at = time();
|
|
||||||
$follow->save();
|
$follow->save();
|
||||||
$isFollowed = true;
|
$isFollowed = true;
|
||||||
|
|
||||||
Notification::newFollower($follow->artist, Auth::user());
|
Notification::newFollower($follow->artist, Auth::user());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,9 +74,9 @@ return [
|
||||||
'pgsql' => [
|
'pgsql' => [
|
||||||
'driver' => 'pgsql',
|
'driver' => 'pgsql',
|
||||||
'host' => env('POSTGRESQL_DB_HOST', 'localhost'),
|
'host' => env('POSTGRESQL_DB_HOST', 'localhost'),
|
||||||
'database' => env('POSTGRESQL_DB_DATABASE', 'forge'),
|
'database' => env('POSTGRESQL_DB_DATABASE', 'homestead'),
|
||||||
'username' => env('POSTGRESQL_DB_USERNAME', 'forge'),
|
'username' => env('POSTGRESQL_DB_USERNAME', 'homestead'),
|
||||||
'password' => env('POSTGRESQL_DB_PASSWORD', ''),
|
'password' => env('POSTGRESQL_DB_PASSWORD', 'secret'),
|
||||||
'charset' => 'utf8',
|
'charset' => 'utf8',
|
||||||
'prefix' => '',
|
'prefix' => '',
|
||||||
'schema' => 'public',
|
'schema' => 'public',
|
||||||
|
|
|
@ -16,7 +16,7 @@ class CreateCommentsTable extends Migration {
|
||||||
{
|
{
|
||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->integer('user_id')->unsigned()->index('comments_user_id_foreign');
|
$table->integer('user_id')->unsigned()->index('comments_user_id_foreign');
|
||||||
$table->string('ip_address', 46);
|
$table->string('ip_address', 46)->nullable();
|
||||||
$table->text('content', 65535);
|
$table->text('content', 65535);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes()->index();
|
$table->softDeletes()->index();
|
||||||
|
|
|
@ -19,7 +19,7 @@ class CreateFavouritesTable extends Migration {
|
||||||
$table->integer('track_id')->unsigned()->nullable()->index();
|
$table->integer('track_id')->unsigned()->nullable()->index();
|
||||||
$table->integer('album_id')->unsigned()->nullable()->index();
|
$table->integer('album_id')->unsigned()->nullable()->index();
|
||||||
$table->integer('playlist_id')->unsigned()->nullable()->index();
|
$table->integer('playlist_id')->unsigned()->nullable()->index();
|
||||||
$table->dateTime('created_at')->default('now()')->nullable();
|
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'))->nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,12 @@ class CreatePlaylistsTable extends Migration {
|
||||||
$table->string('slug');
|
$table->string('slug');
|
||||||
$table->text('description', 65535);
|
$table->text('description', 65535);
|
||||||
$table->unsignedTinyInteger('is_public')->index();
|
$table->unsignedTinyInteger('is_public')->index();
|
||||||
$table->integer('track_count')->unsigned()->index();
|
$table->integer('track_count')->unsigned()->default(0)->index();
|
||||||
$table->integer('view_count')->unsigned();
|
$table->integer('view_count')->unsigned()->default(0);
|
||||||
$table->integer('download_count')->unsigned();
|
$table->integer('download_count')->unsigned()->default(0);
|
||||||
$table->integer('favourite_count')->unsigned();
|
$table->integer('favourite_count')->unsigned()->default(0);
|
||||||
$table->integer('follow_count')->unsigned();
|
$table->integer('follow_count')->unsigned()->default(0);
|
||||||
$table->integer('comment_count')->unsigned();
|
$table->integer('comment_count')->unsigned()->default(0);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->date('deleted_at')->nullable()->index();
|
$table->date('deleted_at')->nullable()->index();
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,12 +20,12 @@ class CreateResourceUsersTable extends Migration {
|
||||||
$table->integer('album_id')->unsigned()->nullable()->index();
|
$table->integer('album_id')->unsigned()->nullable()->index();
|
||||||
$table->integer('playlist_id')->unsigned()->nullable()->index();
|
$table->integer('playlist_id')->unsigned()->nullable()->index();
|
||||||
$table->integer('artist_id')->unsigned()->nullable()->index();
|
$table->integer('artist_id')->unsigned()->nullable()->index();
|
||||||
$table->unsignedTinyInteger('is_followed');
|
$table->unsignedTinyInteger('is_followed')->default(0);
|
||||||
$table->unsignedTinyInteger('is_favourited');
|
$table->unsignedTinyInteger('is_favourited')->default(0);
|
||||||
$table->unsignedTinyInteger('is_pinned');
|
$table->unsignedTinyInteger('is_pinned')->default(0);
|
||||||
$table->integer('view_count');
|
$table->integer('view_count')->default(0);
|
||||||
$table->integer('play_count');
|
$table->integer('play_count')->default(0);
|
||||||
$table->integer('download_count');
|
$table->integer('download_count')->default(0);
|
||||||
$table->unique(['user_id','track_id','album_id','playlist_id','artist_id'], 'resource_unique');
|
$table->unique(['user_id','track_id','album_id','playlist_id','artist_id'], 'resource_unique');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue