#86: More Postgres tweaks

This commit is contained in:
Josef Citrine 2016-06-28 18:53:53 +01:00
parent ab127a0c72
commit 4b0ed2fd1b
7 changed files with 20 additions and 22 deletions

View file

@ -80,7 +80,6 @@ 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;

View file

@ -62,7 +62,6 @@ 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;

View file

@ -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',

View file

@ -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();

View file

@ -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();
}); });
} }

View file

@ -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();
}); });

View file

@ -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');
}); });
} }