From f52d5f2ccf01962124d9dce7dd5d911302a739e2 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sat, 21 Jul 2018 17:13:51 +0930 Subject: [PATCH] No need for deleted_at in notifications table --- ...1_18_133000_change_notifications_columns.php | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/framework/core/migrations/2018_01_18_133000_change_notifications_columns.php b/framework/core/migrations/2018_01_18_133000_change_notifications_columns.php index 963844b02..56fef9ec8 100644 --- a/framework/core/migrations/2018_01_18_133000_change_notifications_columns.php +++ b/framework/core/migrations/2018_01_18_133000_change_notifications_columns.php @@ -9,6 +9,7 @@ * file that was distributed with this source code. */ +use Carbon\Carbon; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Builder; @@ -19,21 +20,15 @@ return [ $table->renameColumn('time', 'created_at'); - $table->timestamp('read_at')->nullable(); - $table->timestamp('deleted_at')->nullable(); + $table->dateTime('read_at')->nullable(); }); $schema->getConnection()->table('notifications') ->where('is_read', 1) - ->update(['read_at' => time()]); - - $schema->getConnection()->table('notifications') - ->where('is_deleted', 1) - ->update(['deleted_at' => time()]); + ->update(['read_at' => Carbon::now()]); $schema->table('notifications', function (Blueprint $table) { $table->dropColumn('is_read'); - $table->dropColumn('is_deleted'); }); }, @@ -45,20 +40,14 @@ return [ $table->renameColumn('created_at', 'time'); $table->boolean('is_read'); - $table->boolean('is_deleted'); }); $schema->getConnection()->table('notifications') ->whereNotNull('read_at') ->update(['is_read' => 1]); - $schema->getConnection()->table('notifications') - ->whereNotNull('deleted_at') - ->update(['is_deleted' => 1]); - $schema->table('notifications', function (Blueprint $table) { $table->dropColumn('read_at'); - $table->dropColumn('deleted_at'); }); } ];