From 15aa4836faa02329a2e7f377ab8dbf127373d0c7 Mon Sep 17 00:00:00 2001 From: jgryspeert Date: Sat, 28 Oct 2023 01:03:16 +0200 Subject: [PATCH 1/2] Enhance Robustness of RemoveViewedAtFromContacts Migration --- ...017_01_28_222114_remove_viewed_at_from_contacts.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/database/migrations/2017_01_28_222114_remove_viewed_at_from_contacts.php b/database/migrations/2017_01_28_222114_remove_viewed_at_from_contacts.php index c572a5a67e8..53d6f014ec4 100644 --- a/database/migrations/2017_01_28_222114_remove_viewed_at_from_contacts.php +++ b/database/migrations/2017_01_28_222114_remove_viewed_at_from_contacts.php @@ -14,9 +14,9 @@ class RemoveViewedAtFromContacts extends Migration public function up() { Schema::table('contacts', function (Blueprint $table) { - $table->dropColumn( - 'viewed_at' - ); + if ($table->hasColumn('viewed_at')) { + $table->dropColumn('viewed_at'); + } }); } @@ -28,7 +28,9 @@ public function up() public function down() { Schema::table('contacts', function (Blueprint $table) { - $table->dateTime('viewed_at')->nullable(); + if ($table->hasColumn('viewed_at')) { + $table->dateTime('viewed_at')->nullable(); + } }); } } From 55a4fdbe7924d931a5976adfed1ed36efaadb6ef Mon Sep 17 00:00:00 2001 From: Alexis Saettler Date: Tue, 31 Oct 2023 10:38:41 +0100 Subject: [PATCH 2/2] Update 2017_01_28_222114_remove_viewed_at_from_contacts.php --- ..._28_222114_remove_viewed_at_from_contacts.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/database/migrations/2017_01_28_222114_remove_viewed_at_from_contacts.php b/database/migrations/2017_01_28_222114_remove_viewed_at_from_contacts.php index 53d6f014ec4..e8c0971d52f 100644 --- a/database/migrations/2017_01_28_222114_remove_viewed_at_from_contacts.php +++ b/database/migrations/2017_01_28_222114_remove_viewed_at_from_contacts.php @@ -13,11 +13,11 @@ class RemoveViewedAtFromContacts extends Migration */ public function up() { - Schema::table('contacts', function (Blueprint $table) { - if ($table->hasColumn('viewed_at')) { + if (Schema::hasColumn('contacts', 'viewed_at')) { + Schema::table('contacts', function (Blueprint $table) { $table->dropColumn('viewed_at'); - } - }); + }); + } } /** @@ -27,10 +27,10 @@ public function up() */ public function down() { - Schema::table('contacts', function (Blueprint $table) { - if ($table->hasColumn('viewed_at')) { + if (! Schema::hasColumn('contacts', 'viewed_at')) { + Schema::table('contacts', function (Blueprint $table) { $table->dateTime('viewed_at')->nullable(); - } - }); + }); + } } }