Use new migration logic

This commit is contained in:
Lance Pioch 2024-09-19 13:19:47 -04:00
parent 9ba8c1df9b
commit 906d4a7d28
5 changed files with 10 additions and 19 deletions

View File

@ -31,6 +31,9 @@ return new class extends Migration
$table->dropIndex('permissions_server_id_foreign'); $table->dropIndex('permissions_server_id_foreign');
$table->dropForeign('permissions_user_id_foreign'); $table->dropForeign('permissions_user_id_foreign');
$table->dropIndex('permissions_user_id_foreign'); $table->dropIndex('permissions_user_id_foreign');
} else {
$table->dropForeign(['server_id']);
$table->dropForeign(['user_id']);
} }
$table->dropColumn('server_id'); $table->dropColumn('server_id');

View File

@ -12,10 +12,7 @@ return new class extends Migration
public function up(): void public function up(): void
{ {
Schema::table('servers', function (Blueprint $table) { Schema::table('servers', function (Blueprint $table) {
if (Schema::getConnection()->getDriverName() !== 'sqlite') {
$table->dropForeign(['pack_id']); $table->dropForeign(['pack_id']);
}
$table->dropColumn('pack_id'); $table->dropColumn('pack_id');
}); });
} }

View File

@ -30,14 +30,15 @@ return new class extends Migration
Schema::table('eggs', function (Blueprint $table) { Schema::table('eggs', function (Blueprint $table) {
if (Schema::getConnection()->getDriverName() !== 'sqlite') { if (Schema::getConnection()->getDriverName() !== 'sqlite') {
$table->dropForeign('service_options_nest_id_foreign'); $table->dropForeign('service_options_nest_id_foreign');
} else {
$table->dropForeign(['nest_id']);
} }
$table->dropColumn('nest_id'); $table->dropColumn('nest_id');
}); });
Schema::table('servers', function (Blueprint $table) { Schema::table('servers', function (Blueprint $table) {
if (Schema::getConnection()->getDriverName() !== 'sqlite') { $table->dropForeign(['nest_id']);
$table->dropForeign('servers_nest_id_foreign');
}
$table->dropColumn('nest_id'); $table->dropColumn('nest_id');
}); });

View File

@ -27,10 +27,7 @@ return new class extends Migration
} }
Schema::table('nodes', function (Blueprint $table) { Schema::table('nodes', function (Blueprint $table) {
if (Schema::getConnection()->getDriverName() !== 'sqlite') { $table->dropForeign(['location_id']);
$table->dropForeign('nodes_location_id_foreign');
}
$table->dropColumn('location_id'); $table->dropColumn('location_id');
}); });

View File

@ -43,15 +43,8 @@ return new class extends Migration
$server->save(); $server->save();
} }
try {
Schema::table('servers', function (Blueprint $table) { Schema::table('servers', function (Blueprint $table) {
$table->dropForeign(['allocation_id']); $table->dropForeign(['allocation_id']);
});
} catch (Throwable) {
// pass for databases that don't support this like sqlite
}
Schema::table('servers', function (Blueprint $table) {
$table->dropUnique(['allocation_id']); $table->dropUnique(['allocation_id']);
$table->dropColumn(['allocation_id']); $table->dropColumn(['allocation_id']);
}); });