From 906d4a7d28febd6225a899d65fb57a536e190e96 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Thu, 19 Sep 2024 13:19:47 -0400 Subject: [PATCH] Use new migration logic --- .../2017_02_09_174834_SetupPermissionsPivotTable.php | 3 +++ .../2020_09_13_110007_drop_packs_from_servers.php | 5 +---- .../migrations/2024_03_12_154408_remove_nests_table.php | 7 ++++--- .../2024_03_14_055537_remove_locations_table.php | 5 +---- .../migrations/2024_09_18_043350_modify_allocations.php | 9 +-------- 5 files changed, 10 insertions(+), 19 deletions(-) diff --git a/database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php b/database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php index ca2cabfd6..2c16118d4 100644 --- a/database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php +++ b/database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php @@ -31,6 +31,9 @@ return new class extends Migration $table->dropIndex('permissions_server_id_foreign'); $table->dropForeign('permissions_user_id_foreign'); $table->dropIndex('permissions_user_id_foreign'); + } else { + $table->dropForeign(['server_id']); + $table->dropForeign(['user_id']); } $table->dropColumn('server_id'); diff --git a/database/migrations/2020_09_13_110007_drop_packs_from_servers.php b/database/migrations/2020_09_13_110007_drop_packs_from_servers.php index cc2695edd..39f048b37 100644 --- a/database/migrations/2020_09_13_110007_drop_packs_from_servers.php +++ b/database/migrations/2020_09_13_110007_drop_packs_from_servers.php @@ -12,10 +12,7 @@ return new class extends Migration public function up(): void { Schema::table('servers', function (Blueprint $table) { - if (Schema::getConnection()->getDriverName() !== 'sqlite') { - $table->dropForeign(['pack_id']); - } - + $table->dropForeign(['pack_id']); $table->dropColumn('pack_id'); }); } diff --git a/database/migrations/2024_03_12_154408_remove_nests_table.php b/database/migrations/2024_03_12_154408_remove_nests_table.php index cc95a5f8e..42d1315b9 100644 --- a/database/migrations/2024_03_12_154408_remove_nests_table.php +++ b/database/migrations/2024_03_12_154408_remove_nests_table.php @@ -30,14 +30,15 @@ return new class extends Migration Schema::table('eggs', function (Blueprint $table) { if (Schema::getConnection()->getDriverName() !== 'sqlite') { $table->dropForeign('service_options_nest_id_foreign'); + } else { + $table->dropForeign(['nest_id']); } + $table->dropColumn('nest_id'); }); Schema::table('servers', function (Blueprint $table) { - if (Schema::getConnection()->getDriverName() !== 'sqlite') { - $table->dropForeign('servers_nest_id_foreign'); - } + $table->dropForeign(['nest_id']); $table->dropColumn('nest_id'); }); diff --git a/database/migrations/2024_03_14_055537_remove_locations_table.php b/database/migrations/2024_03_14_055537_remove_locations_table.php index f06ded66f..bdd0c382a 100644 --- a/database/migrations/2024_03_14_055537_remove_locations_table.php +++ b/database/migrations/2024_03_14_055537_remove_locations_table.php @@ -27,10 +27,7 @@ return new class extends Migration } Schema::table('nodes', function (Blueprint $table) { - if (Schema::getConnection()->getDriverName() !== 'sqlite') { - $table->dropForeign('nodes_location_id_foreign'); - } - + $table->dropForeign(['location_id']); $table->dropColumn('location_id'); }); diff --git a/database/migrations/2024_09_18_043350_modify_allocations.php b/database/migrations/2024_09_18_043350_modify_allocations.php index 418b26ed9..92e59495e 100644 --- a/database/migrations/2024_09_18_043350_modify_allocations.php +++ b/database/migrations/2024_09_18_043350_modify_allocations.php @@ -43,15 +43,8 @@ return new class extends Migration $server->save(); } - try { - Schema::table('servers', function (Blueprint $table) { - $table->dropForeign(['allocation_id']); - }); - } catch (Throwable) { - // pass for databases that don't support this like sqlite - } - Schema::table('servers', function (Blueprint $table) { + $table->dropForeign(['allocation_id']); $table->dropUnique(['allocation_id']); $table->dropColumn(['allocation_id']); });