Skip to content

Commit

Permalink
Use new migration logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lancepioch committed Sep 19, 2024
1 parent 9ba8c1d commit 906d4a7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public function up(): void
$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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
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');
});
}
Expand Down
7 changes: 4 additions & 3 deletions database/migrations/2024_03_12_154408_remove_nests_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ public function up(): void
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');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ public function up(): void
}

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

Expand Down
9 changes: 1 addition & 8 deletions database/migrations/2024_09_18_043350_modify_allocations.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,8 @@ public function up(): void
$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']);
});
Expand Down

0 comments on commit 906d4a7

Please sign in to comment.