diff --git a/app/Filament/Resources/EggResource/Pages/CreateEgg.php b/app/Filament/Resources/EggResource/Pages/CreateEgg.php index 4b1928ed1..517095fb2 100644 --- a/app/Filament/Resources/EggResource/Pages/CreateEgg.php +++ b/app/Filament/Resources/EggResource/Pages/CreateEgg.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\EggResource\Pages; use App\Filament\Resources\EggResource; -use App\Models\User; use Filament\Resources\Pages\CreateRecord; use AbdelhamidErrahmouni\FilamentMonacoEditor\MonacoEditor; use Filament\Forms; diff --git a/database/migrations/2016_03_18_155649_add_nullable_field_lastrun.php b/database/migrations/2016_03_18_155649_add_nullable_field_lastrun.php index 3eaf06a87..8e674dda6 100644 --- a/database/migrations/2016_03_18_155649_add_nullable_field_lastrun.php +++ b/database/migrations/2016_03_18_155649_add_nullable_field_lastrun.php @@ -1,6 +1,8 @@ wrapTable('tasks'); - DB::statement('ALTER TABLE ' . $table . ' CHANGE `last_run` `last_run` TIMESTAMP NULL;'); + Schema::table('tasks', function (Blueprint $table) { + $table->timestamp('last_run')->nullable()->change(); + }); } /** @@ -18,7 +21,8 @@ return new class extends Migration */ public function down(): void { - $table = DB::getQueryGrammar()->wrapTable('tasks'); - DB::statement('ALTER TABLE ' . $table . ' CHANGE `last_run` `last_run` TIMESTAMP;'); + Schema::table('tasks', function (Blueprint $table) { + $table->timestamp('last_run')->change(); + }); } }; diff --git a/database/migrations/2016_10_23_193810_add_foreign_keys_servers.php b/database/migrations/2016_10_23_193810_add_foreign_keys_servers.php index 7301caa75..e847e801d 100644 --- a/database/migrations/2016_10_23_193810_add_foreign_keys_servers.php +++ b/database/migrations/2016_10_23_193810_add_foreign_keys_servers.php @@ -11,13 +11,14 @@ return new class extends Migration */ public function up(): void { - DB::statement('ALTER TABLE servers - MODIFY COLUMN node INT(10) UNSIGNED NOT NULL, - MODIFY COLUMN owner INT(10) UNSIGNED NOT NULL, - MODIFY COLUMN allocation INT(10) UNSIGNED NOT NULL, - MODIFY COLUMN service INT(10) UNSIGNED NOT NULL, - MODIFY COLUMN `option` INT(10) UNSIGNED NOT NULL - '); + + Schema::table('servers', function (Blueprint $table) { + $table->unsignedInteger('node')->change(); + $table->unsignedInteger('owner')->change(); + $table->unsignedInteger('allocation')->change(); + $table->unsignedInteger('service')->change(); + $table->unsignedInteger('option')->change(); + }); Schema::table('servers', function (Blueprint $table) { $table->foreign('node')->references('id')->on('nodes'); @@ -50,12 +51,12 @@ return new class extends Migration $table->dropColumn('deleted_at'); }); - DB::statement('ALTER TABLE servers - MODIFY COLUMN node MEDIUMINT(8) UNSIGNED NOT NULL, - MODIFY COLUMN owner MEDIUMINT(8) UNSIGNED NOT NULL, - MODIFY COLUMN allocation MEDIUMINT(8) UNSIGNED NOT NULL, - MODIFY COLUMN service MEDIUMINT(8) UNSIGNED NOT NULL, - MODIFY COLUMN `option` MEDIUMINT(8) UNSIGNED NOT NULL - '); + Schema::table('servers', function (Blueprint $table) { + $table->unsignedMediumInteger('node')->change(); + $table->unsignedMediumInteger('owner')->change(); + $table->unsignedMediumInteger('allocation')->change(); + $table->unsignedMediumInteger('service')->change(); + $table->unsignedMediumInteger('option')->change(); + }); } }; diff --git a/database/migrations/2016_10_23_201624_add_foreign_allocations.php b/database/migrations/2016_10_23_201624_add_foreign_allocations.php index 76a6a141f..b401f8fa2 100644 --- a/database/migrations/2016_10_23_201624_add_foreign_allocations.php +++ b/database/migrations/2016_10_23_201624_add_foreign_allocations.php @@ -11,10 +11,10 @@ return new class extends Migration */ public function up(): void { - DB::statement('ALTER TABLE allocations - MODIFY COLUMN assigned_to INT(10) UNSIGNED NULL, - MODIFY COLUMN node INT(10) UNSIGNED NOT NULL - '); + Schema::table('allocations', function (Blueprint $table) { + $table->unsignedInteger('assigned_to')->change(); + $table->unsignedInteger('node')->change(); + }); Schema::table('allocations', function (Blueprint $table) { $table->foreign('assigned_to')->references('id')->on('servers'); @@ -35,9 +35,9 @@ return new class extends Migration $table->dropIndex('allocations_node_foreign'); }); - DB::statement('ALTER TABLE allocations - MODIFY COLUMN assigned_to MEDIUMINT(8) UNSIGNED NULL, - MODIFY COLUMN node MEDIUMINT(8) UNSIGNED NOT NULL - '); + Schema::table('allocations', function (Blueprint $table) { + $table->unsignedMediumInteger('assigned_to')->change(); + $table->unsignedMediumInteger('node')->change(); + }); } }; diff --git a/database/migrations/2016_10_23_202703_add_foreign_api_permissions.php b/database/migrations/2016_10_23_202703_add_foreign_api_permissions.php index 8b3322a60..62812f4d5 100644 --- a/database/migrations/2016_10_23_202703_add_foreign_api_permissions.php +++ b/database/migrations/2016_10_23_202703_add_foreign_api_permissions.php @@ -11,7 +11,9 @@ return new class extends Migration */ public function up(): void { - DB::statement('ALTER TABLE api_permissions MODIFY key_id INT(10) UNSIGNED NOT NULL'); + Schema::table('api_permissions', function (Blueprint $table) { + $table->unsignedInteger('key_id')->change(); + }); Schema::table('api_permissions', function (Blueprint $table) { $table->foreign('key_id')->references('id')->on('api_keys'); @@ -28,6 +30,8 @@ return new class extends Migration $table->dropIndex('api_permissions_key_id_foreign'); }); - DB::statement('ALTER TABLE api_permissions MODIFY key_id MEDIUMINT(8) UNSIGNED NOT NULL'); + Schema::table('api_permissions', function (Blueprint $table) { + $table->unsignedMediumInteger('key_id')->change(); + }); } }; diff --git a/database/migrations/2016_10_23_203335_add_foreign_nodes.php b/database/migrations/2016_10_23_203335_add_foreign_nodes.php index 9d8d57249..4cd0a8a63 100644 --- a/database/migrations/2016_10_23_203335_add_foreign_nodes.php +++ b/database/migrations/2016_10_23_203335_add_foreign_nodes.php @@ -11,7 +11,9 @@ return new class extends Migration */ public function up(): void { - DB::statement('ALTER TABLE nodes MODIFY location INT(10) UNSIGNED NOT NULL'); + Schema::table('nodes', function (Blueprint $table) { + $table->unsignedInteger('location')->change(); + }); Schema::table('nodes', function (Blueprint $table) { $table->foreign('location')->references('id')->on('locations'); @@ -28,6 +30,8 @@ return new class extends Migration $table->dropIndex('nodes_location_foreign'); }); - DB::statement('ALTER TABLE nodes MODIFY location MEDIUMINT(10) UNSIGNED NOT NULL'); + Schema::table('nodes', function (Blueprint $table) { + $table->unsignedMediumInteger('location')->change(); + }); } }; diff --git a/database/migrations/2016_10_23_203857_add_foreign_server_variables.php b/database/migrations/2016_10_23_203857_add_foreign_server_variables.php index 4c3c38258..628d5f157 100644 --- a/database/migrations/2016_10_23_203857_add_foreign_server_variables.php +++ b/database/migrations/2016_10_23_203857_add_foreign_server_variables.php @@ -11,10 +11,10 @@ return new class extends Migration */ public function up(): void { - DB::statement('ALTER TABLE server_variables - MODIFY COLUMN server_id INT(10) UNSIGNED NULL, - MODIFY COLUMN variable_id INT(10) UNSIGNED NOT NULL - '); + Schema::table('server_variables', function (Blueprint $table) { + $table->unsignedInteger('server_id')->change(); + $table->unsignedInteger('variable_id')->change(); + }); Schema::table('server_variables', function (Blueprint $table) { $table->foreign('server_id')->references('id')->on('servers'); @@ -32,9 +32,10 @@ return new class extends Migration $table->dropForeign(['variable_id']); }); - DB::statement('ALTER TABLE server_variables - MODIFY COLUMN server_id MEDIUMINT(8) UNSIGNED NULL, - MODIFY COLUMN variable_id MEDIUMINT(8) UNSIGNED NOT NULL - '); + Schema::table('server_variables', function (Blueprint $table) { + $table->unsignedMediumInteger('server_id')->change(); + $table->unsignedMediumInteger('variable_id')->change(); + }); + } }; diff --git a/database/migrations/2016_10_23_204157_add_foreign_service_options.php b/database/migrations/2016_10_23_204157_add_foreign_service_options.php index ad445dcfa..e691bba7f 100644 --- a/database/migrations/2016_10_23_204157_add_foreign_service_options.php +++ b/database/migrations/2016_10_23_204157_add_foreign_service_options.php @@ -11,7 +11,9 @@ return new class extends Migration */ public function up(): void { - DB::statement('ALTER TABLE service_options MODIFY parent_service INT(10) UNSIGNED NOT NULL'); + Schema::table('service_options', function (Blueprint $table) { + $table->unsignedInteger('parent_service')->change(); + }); Schema::table('service_options', function (Blueprint $table) { $table->foreign('parent_service')->references('id')->on('services'); @@ -28,6 +30,8 @@ return new class extends Migration $table->dropIndex('service_options_parent_service_foreign'); }); - DB::statement('ALTER TABLE service_options MODIFY parent_service MEDIUMINT(8) UNSIGNED NOT NULL'); + Schema::table('service_options', function (Blueprint $table) { + $table->unsignedMediumInteger('parent_service')->change(); + }); } }; diff --git a/database/migrations/2016_10_23_204321_add_foreign_service_variables.php b/database/migrations/2016_10_23_204321_add_foreign_service_variables.php index 6c45c53e0..17a71edfc 100644 --- a/database/migrations/2016_10_23_204321_add_foreign_service_variables.php +++ b/database/migrations/2016_10_23_204321_add_foreign_service_variables.php @@ -11,7 +11,9 @@ return new class extends Migration */ public function up(): void { - DB::statement('ALTER TABLE service_variables MODIFY option_id INT(10) UNSIGNED NOT NULL'); + Schema::table('service_variables', function (Blueprint $table) { + $table->unsignedInteger('option_id')->change(); + }); Schema::table('service_variables', function (Blueprint $table) { $table->foreign('option_id')->references('id')->on('service_options'); @@ -28,6 +30,8 @@ return new class extends Migration $table->dropIndex('service_variables_option_id_foreign'); }); - DB::statement('ALTER TABLE service_variables MODIFY option_id MEDIUMINT(8) UNSIGNED NOT NULL'); + Schema::table('service_variables', function (Blueprint $table) { + $table->unsignedMediumInteger('option_id')->change(); + }); } }; diff --git a/database/migrations/2017_02_02_175548_UpdateColumnNames.php b/database/migrations/2017_02_02_175548_UpdateColumnNames.php index 0c8b34149..1ef3415e4 100644 --- a/database/migrations/2017_02_02_175548_UpdateColumnNames.php +++ b/database/migrations/2017_02_02_175548_UpdateColumnNames.php @@ -12,19 +12,21 @@ return new class extends Migration public function up(): void { Schema::table('servers', function (Blueprint $table) { - $table->dropForeign('servers_node_foreign'); - $table->dropForeign('servers_owner_foreign'); - $table->dropForeign('servers_allocation_foreign'); - $table->dropForeign('servers_service_foreign'); - $table->dropForeign('servers_option_foreign'); - $table->dropForeign('servers_pack_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('servers_node_foreign'); + $table->dropForeign('servers_owner_foreign'); + $table->dropForeign('servers_allocation_foreign'); + $table->dropForeign('servers_service_foreign'); + $table->dropForeign('servers_option_foreign'); + $table->dropForeign('servers_pack_foreign'); - $table->dropIndex('servers_node_foreign'); - $table->dropIndex('servers_owner_foreign'); - $table->dropIndex('servers_allocation_foreign'); - $table->dropIndex('servers_service_foreign'); - $table->dropIndex('servers_option_foreign'); - $table->dropIndex('servers_pack_foreign'); + $table->dropIndex('servers_node_foreign'); + $table->dropIndex('servers_owner_foreign'); + $table->dropIndex('servers_allocation_foreign'); + $table->dropIndex('servers_service_foreign'); + $table->dropIndex('servers_option_foreign'); + $table->dropIndex('servers_pack_foreign'); + } $table->renameColumn('node', 'node_id'); $table->renameColumn('owner', 'owner_id'); @@ -50,11 +52,13 @@ return new class extends Migration public function down(): void { Schema::table('servers', function (Blueprint $table) { - $table->dropForeign(['node_id']); - $table->dropForeign(['owner_id']); - $table->dropForeign(['allocation_id']); - $table->dropForeign(['service_id']); - $table->dropForeign(['option_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['node_id']); + $table->dropForeign(['owner_id']); + $table->dropForeign(['allocation_id']); + $table->dropForeign(['service_id']); + $table->dropForeign(['option_id']); + } $table->renameColumn('node_id', 'node'); $table->renameColumn('owner_id', 'owner'); diff --git a/database/migrations/2017_02_03_140948_UpdateNodesTable.php b/database/migrations/2017_02_03_140948_UpdateNodesTable.php index a46be44a2..72f560f39 100644 --- a/database/migrations/2017_02_03_140948_UpdateNodesTable.php +++ b/database/migrations/2017_02_03_140948_UpdateNodesTable.php @@ -12,8 +12,10 @@ return new class extends Migration public function up(): void { Schema::table('nodes', function (Blueprint $table) { - $table->dropForeign('nodes_location_foreign'); - $table->dropIndex('nodes_location_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('nodes_location_foreign'); + $table->dropIndex('nodes_location_foreign'); + } $table->renameColumn('location', 'location_id'); $table->foreign('location_id')->references('id')->on('locations'); @@ -26,8 +28,10 @@ return new class extends Migration public function down(): void { Schema::table('nodes', function (Blueprint $table) { - $table->dropForeign('nodes_location_id_foreign'); - $table->dropIndex('nodes_location_id_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('nodes_location_id_foreign'); + $table->dropIndex('nodes_location_id_foreign'); + } $table->renameColumn('location_id', 'location'); $table->foreign('location')->references('id')->on('locations'); diff --git a/database/migrations/2017_02_03_155554_RenameColumns.php b/database/migrations/2017_02_03_155554_RenameColumns.php index 250689a71..400241e88 100644 --- a/database/migrations/2017_02_03_155554_RenameColumns.php +++ b/database/migrations/2017_02_03_155554_RenameColumns.php @@ -12,10 +12,12 @@ return new class extends Migration public function up(): void { Schema::table('allocations', function (Blueprint $table) { - $table->dropForeign('allocations_node_foreign'); - $table->dropForeign('allocations_assigned_to_foreign'); - $table->dropIndex('allocations_node_foreign'); - $table->dropIndex('allocations_assigned_to_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('allocations_node_foreign'); + $table->dropForeign('allocations_assigned_to_foreign'); + $table->dropIndex('allocations_node_foreign'); + $table->dropIndex('allocations_assigned_to_foreign'); + } $table->renameColumn('node', 'node_id'); $table->renameColumn('assigned_to', 'server_id'); @@ -30,10 +32,12 @@ return new class extends Migration public function down(): void { Schema::table('allocations', function (Blueprint $table) { - $table->dropForeign('allocations_node_id_foreign'); - $table->dropForeign('allocations_server_id_foreign'); - $table->dropIndex('allocations_node_id_foreign'); - $table->dropIndex('allocations_server_id_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('allocations_node_id_foreign'); + $table->dropForeign('allocations_server_id_foreign'); + $table->dropIndex('allocations_node_id_foreign'); + $table->dropIndex('allocations_server_id_foreign'); + } $table->renameColumn('node_id', 'node'); $table->renameColumn('server_id', 'assigned_to'); diff --git a/database/migrations/2017_02_05_164123_AdjustColumnNames.php b/database/migrations/2017_02_05_164123_AdjustColumnNames.php index fc6ecaaa8..e299b62f6 100644 --- a/database/migrations/2017_02_05_164123_AdjustColumnNames.php +++ b/database/migrations/2017_02_05_164123_AdjustColumnNames.php @@ -12,8 +12,10 @@ return new class extends Migration public function up(): void { Schema::table('service_options', function (Blueprint $table) { - $table->dropForeign('service_options_parent_service_foreign'); - $table->dropIndex('service_options_parent_service_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('service_options_parent_service_foreign'); + $table->dropIndex('service_options_parent_service_foreign'); + } $table->renameColumn('parent_service', 'service_id'); $table->foreign('service_id')->references('id')->on('services'); @@ -26,8 +28,10 @@ return new class extends Migration public function down(): void { Schema::table('service_options', function (Blueprint $table) { - $table->dropForeign('service_options_service_id_foreign'); - $table->dropIndex('service_options_service_id_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('service_options_service_id_foreign'); + $table->dropIndex('service_options_service_id_foreign'); + } $table->renameColumn('service_id', 'parent_service'); $table->foreign('parent_service')->references('id')->on('services'); diff --git a/database/migrations/2017_02_05_164516_AdjustColumnNamesForServicePacks.php b/database/migrations/2017_02_05_164516_AdjustColumnNamesForServicePacks.php index a1ba015b4..352b26443 100644 --- a/database/migrations/2017_02_05_164516_AdjustColumnNamesForServicePacks.php +++ b/database/migrations/2017_02_05_164516_AdjustColumnNamesForServicePacks.php @@ -12,8 +12,10 @@ return new class extends Migration public function up(): void { Schema::table('service_packs', function (Blueprint $table) { - $table->dropForeign('service_packs_option_foreign'); - $table->dropIndex('service_packs_option_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('service_packs_option_foreign'); + $table->dropIndex('service_packs_option_foreign'); + } $table->renameColumn('option', 'option_id'); $table->foreign('option_id')->references('id')->on('service_options'); @@ -26,8 +28,10 @@ return new class extends Migration public function down(): void { Schema::table('service_packs', function (Blueprint $table) { - $table->dropForeign('service_packs_option_id_foreign'); - $table->dropIndex('service_packs_option_id_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('service_packs_option_id_foreign'); + $table->dropIndex('service_packs_option_id_foreign'); + } $table->renameColumn('option_id', 'option'); $table->foreign('option')->references('id')->on('service_options'); diff --git a/database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php b/database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php index 2a51fb015..ca2cabfd6 100644 --- a/database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php +++ b/database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php @@ -26,10 +26,12 @@ return new class extends Migration }); Schema::table('permissions', function (Blueprint $table) { - $table->dropForeign('permissions_server_id_foreign'); - $table->dropIndex('permissions_server_id_foreign'); - $table->dropForeign('permissions_user_id_foreign'); - $table->dropIndex('permissions_user_id_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('permissions_server_id_foreign'); + $table->dropIndex('permissions_server_id_foreign'); + $table->dropForeign('permissions_user_id_foreign'); + $table->dropIndex('permissions_user_id_foreign'); + } $table->dropColumn('server_id'); $table->dropColumn('user_id'); @@ -60,8 +62,10 @@ return new class extends Migration }); Schema::table('permissions', function (Blueprint $table) { - $table->dropForeign('permissions_subuser_id_foreign'); - $table->dropIndex('permissions_subuser_id_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('permissions_subuser_id_foreign'); + $table->dropIndex('permissions_subuser_id_foreign'); + } $table->dropColumn('subuser_id'); $table->foreign('server_id')->references('id')->on('servers'); diff --git a/database/migrations/2017_02_10_171858_UpdateAPIKeyColumnNames.php b/database/migrations/2017_02_10_171858_UpdateAPIKeyColumnNames.php index 7411fd183..177d59952 100644 --- a/database/migrations/2017_02_10_171858_UpdateAPIKeyColumnNames.php +++ b/database/migrations/2017_02_10_171858_UpdateAPIKeyColumnNames.php @@ -12,7 +12,10 @@ return new class extends Migration public function up(): void { Schema::table('api_keys', function (Blueprint $table) { - $table->dropForeign('api_keys_user_foreign')->dropIndex('api_keys_user_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('api_keys_user_foreign'); + $table->dropIndex('api_keys_user_foreign'); + } $table->renameColumn('user', 'user_id'); $table->foreign('user_id')->references('id')->on('users'); @@ -25,7 +28,10 @@ return new class extends Migration public function down(): void { Schema::table('api_keys', function (Blueprint $table) { - $table->dropForeign('api_keys_user_id_foreign')->dropIndex('api_keys_user_id_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('api_keys_user_id_foreign'); + $table->dropIndex('api_keys_user_id_foreign'); + } $table->renameColumn('user_id', 'user'); $table->foreign('user')->references('id')->on('users'); diff --git a/database/migrations/2017_03_03_224254_UpdateNodeConfigTokensColumns.php b/database/migrations/2017_03_03_224254_UpdateNodeConfigTokensColumns.php index e40823792..1f348bf64 100644 --- a/database/migrations/2017_03_03_224254_UpdateNodeConfigTokensColumns.php +++ b/database/migrations/2017_03_03_224254_UpdateNodeConfigTokensColumns.php @@ -12,7 +12,10 @@ return new class extends Migration public function up(): void { Schema::table('node_configuration_tokens', function (Blueprint $table) { - $table->dropForeign(['node']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['node']); + } + $table->dropColumn('expires_at'); $table->renameColumn('node', 'node_id'); @@ -26,7 +29,10 @@ return new class extends Migration public function down(): void { Schema::table('node_configuration_tokens', function (Blueprint $table) { - $table->dropForeign(['node_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['node_id']); + } + $table->renameColumn('node_id', 'node'); $table->timestamp('expires_at')->after('token'); diff --git a/database/migrations/2017_03_14_175631_RenameServicePacksToSingluarPacks.php b/database/migrations/2017_03_14_175631_RenameServicePacksToSingluarPacks.php index 87496540d..12fc9cc21 100644 --- a/database/migrations/2017_03_14_175631_RenameServicePacksToSingluarPacks.php +++ b/database/migrations/2017_03_14_175631_RenameServicePacksToSingluarPacks.php @@ -11,9 +11,11 @@ return new class extends Migration */ public function up(): void { - Schema::table('service_packs', function (Blueprint $table) { - $table->dropForeign(['option_id']); - }); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + Schema::table('service_packs', function (Blueprint $table) { + $table->dropForeign(['option_id']); + }); + } Schema::rename('service_packs', 'packs'); @@ -27,9 +29,11 @@ return new class extends Migration */ public function down(): void { - Schema::table('packs', function (Blueprint $table) { - $table->dropForeign(['option_id']); - }); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + Schema::table('packs', function (Blueprint $table) { + $table->dropForeign(['option_id']); + }); + } Schema::rename('packs', 'service_packs'); diff --git a/database/migrations/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php b/database/migrations/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php index c0c271f7d..fc2a91378 100644 --- a/database/migrations/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php +++ b/database/migrations/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php @@ -11,9 +11,11 @@ return new class extends Migration */ public function up(): void { - Schema::table('database_servers', function (Blueprint $table) { - $table->dropForeign(['linked_node']); - }); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + Schema::table('database_servers', function (Blueprint $table) { + $table->dropForeign(['linked_node']); + }); + } Schema::rename('database_servers', 'database_hosts'); @@ -29,9 +31,11 @@ return new class extends Migration */ public function down(): void { - Schema::table('database_hosts', function (Blueprint $table) { - $table->dropForeign(['node_id']); - }); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + Schema::table('database_hosts', function (Blueprint $table) { + $table->dropForeign(['node_id']); + }); + } Schema::rename('database_hosts', 'database_servers'); diff --git a/database/migrations/2017_03_16_181515_CleanupDatabasesDatabase.php b/database/migrations/2017_03_16_181515_CleanupDatabasesDatabase.php index e53078a1b..ee760a9a2 100644 --- a/database/migrations/2017_03_16_181515_CleanupDatabasesDatabase.php +++ b/database/migrations/2017_03_16_181515_CleanupDatabasesDatabase.php @@ -12,7 +12,9 @@ return new class extends Migration public function up(): void { Schema::table('databases', function (Blueprint $table) { - $table->dropForeign(['db_server']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['db_server']); + } $table->renameColumn('db_server', 'database_host_id'); @@ -26,7 +28,9 @@ return new class extends Migration public function down(): void { Schema::table('databases', function (Blueprint $table) { - $table->dropForeign(['database_host_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['database_host_id']); + } $table->renameColumn('database_host_id', 'db_server'); diff --git a/database/migrations/2017_04_15_125021_UpgradeTaskSystem.php b/database/migrations/2017_04_15_125021_UpgradeTaskSystem.php index 195a6559b..542e3a3a8 100644 --- a/database/migrations/2017_04_15_125021_UpgradeTaskSystem.php +++ b/database/migrations/2017_04_15_125021_UpgradeTaskSystem.php @@ -13,7 +13,9 @@ return new class extends Migration public function up(): void { Schema::table('tasks', function (Blueprint $table) { - $table->dropForeign(['server']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['server']); + } $table->renameColumn('server', 'server_id'); $table->unsignedInteger('user_id')->nullable()->after('id'); @@ -36,8 +38,10 @@ return new class extends Migration public function down(): void { Schema::table('tasks', function (Blueprint $table) { - // $table->dropForeign(['server_id']); - // $table->dropForeign(['user_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['server_id']); + $table->dropForeign(['user_id']); + } $table->renameColumn('server_id', 'server'); $table->dropColumn('user_id'); diff --git a/database/migrations/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php b/database/migrations/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php index 4ff8d2018..eb88463c2 100644 --- a/database/migrations/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php +++ b/database/migrations/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php @@ -12,7 +12,9 @@ return new class extends Migration public function up(): void { Schema::table('api_permissions', function (Blueprint $table) { - $table->dropForeign(['key_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['key_id']); + } $table->foreign('key_id')->references('id')->on('api_keys')->onDelete('cascade'); }); @@ -24,7 +26,9 @@ return new class extends Migration public function down(): void { Schema::table('api_permissions', function (Blueprint $table) { - $table->dropForeign(['key_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['key_id']); + } $table->foreign('key_id')->references('id')->on('api_keys'); }); diff --git a/database/migrations/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php b/database/migrations/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php index a3dc806d5..89baae6f0 100644 --- a/database/migrations/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php +++ b/database/migrations/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php @@ -12,14 +12,18 @@ return new class extends Migration public function up(): void { Schema::table('permissions', function (Blueprint $table) { - $table->dropForeign(['subuser_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['subuser_id']); + } $table->foreign('subuser_id')->references('id')->on('subusers')->onDelete('cascade'); }); Schema::table('subusers', function (Blueprint $table) { - $table->dropForeign(['user_id']); - $table->dropForeign(['server_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['user_id']); + $table->dropForeign(['server_id']); + } $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('server_id')->references('id')->on('servers')->onDelete('cascade'); @@ -32,15 +36,19 @@ return new class extends Migration public function down(): void { Schema::table('subusers', function (Blueprint $table) { - $table->dropForeign(['user_id']); - $table->dropForeign(['server_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['user_id']); + $table->dropForeign(['server_id']); + } $table->foreign('user_id')->references('id')->on('users'); $table->foreign('server_id')->references('id')->on('servers'); }); Schema::table('permissions', function (Blueprint $table) { - $table->dropForeign(['subuser_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['subuser_id']); + } $table->foreign('subuser_id')->references('id')->on('subusers'); }); diff --git a/database/migrations/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php b/database/migrations/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php index 23f57020f..0d80e32a3 100644 --- a/database/migrations/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php +++ b/database/migrations/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php @@ -12,7 +12,9 @@ return new class extends Migration public function up(): void { Schema::table('allocations', function (Blueprint $table) { - $table->dropForeign(['server_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['server_id']); + } $table->foreign('server_id')->references('id')->on('servers')->onDelete('set null'); }); @@ -24,7 +26,9 @@ return new class extends Migration public function down(): void { Schema::table('allocations', function (Blueprint $table) { - $table->dropForeign(['server_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['server_id']); + } $table->foreign('server_id')->references('id')->on('servers'); }); diff --git a/database/migrations/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php b/database/migrations/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php index 82f591b05..60320b1d9 100644 --- a/database/migrations/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php +++ b/database/migrations/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php @@ -12,8 +12,10 @@ return new class extends Migration public function up(): void { Schema::table('server_variables', function (Blueprint $table) { - $table->dropForeign(['server_id']); - $table->dropForeign(['variable_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['server_id']); + $table->dropForeign(['variable_id']); + } $table->foreign('server_id')->references('id')->on('servers')->onDelete('cascade'); $table->foreign('variable_id')->references('id')->on('service_variables')->onDelete('cascade'); @@ -26,8 +28,10 @@ return new class extends Migration public function down(): void { Schema::table('server_variables', function (Blueprint $table) { - $table->dropForeign(['server_id']); - $table->dropForeign(['variable_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['server_id']); + $table->dropForeign(['variable_id']); + } $table->foreign('server_id')->references('id')->on('servers'); $table->foreign('variable_id')->references('id')->on('service_variables'); diff --git a/database/migrations/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php b/database/migrations/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php index dedc2879d..f3b0b0e2b 100644 --- a/database/migrations/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php +++ b/database/migrations/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php @@ -12,7 +12,9 @@ return new class extends Migration public function up(): void { Schema::table('tasks', function (Blueprint $table) { - $table->dropForeign(['server_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['server_id']); + } $table->foreign('server_id')->references('id')->on('servers')->onDelete('cascade'); }); diff --git a/database/migrations/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php b/database/migrations/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php index a7822836d..41b85372f 100644 --- a/database/migrations/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php +++ b/database/migrations/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php @@ -12,7 +12,9 @@ return new class extends Migration public function up(): void { Schema::table('database_hosts', function (Blueprint $table) { - $table->dropForeign(['node_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['node_id']); + } $table->foreign('node_id')->references('id')->on('nodes')->onDelete('set null'); }); } @@ -23,7 +25,9 @@ return new class extends Migration public function down(): void { Schema::table('database_hosts', function (Blueprint $table) { - $table->dropForeign(['node_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['node_id']); + } $table->foreign('node_id')->references('id')->on('nodes'); }); } diff --git a/database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php b/database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php index da0a658a6..2072a3f18 100644 --- a/database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php +++ b/database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php @@ -23,8 +23,8 @@ return new class extends Migration public function down(): void { Schema::table('nodes', function (Blueprint $table) { - DB::statement('ALTER TABLE nodes MODIFY disk_overallocate MEDIUMINT UNSIGNED NULL, - MODIFY memory_overallocate MEDIUMINT UNSIGNED NULL'); + $table->unsignedMediumInteger('disk_overallocate')->nullable(); + $table->unsignedMediumInteger('memory_overallocate')->nullable(); }); } }; diff --git a/database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php b/database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php index bc55bafe7..a0a162f0b 100644 --- a/database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php +++ b/database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php @@ -22,7 +22,9 @@ return new class extends Migration public function down(): void { Schema::table('allocations', function (Blueprint $table) { - $table->dropForeign(['node_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['node_id']); + } $table->dropUnique(['node_id', 'ip', 'port']); $table->foreign('node_id')->references('id')->on('nodes'); }); diff --git a/database/migrations/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php b/database/migrations/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php index a1c50d4ab..a7ffe4042 100644 --- a/database/migrations/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php +++ b/database/migrations/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php @@ -12,7 +12,9 @@ return new class extends Migration public function up(): void { Schema::table('service_options', function (Blueprint $table) { - $table->dropForeign(['service_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['service_id']); + } $table->foreign('service_id')->references('id')->on('services')->onDelete('cascade'); }); @@ -24,7 +26,9 @@ return new class extends Migration public function down(): void { Schema::table('service_options', function (Blueprint $table) { - $table->dropForeign(['service_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['service_id']); + } $table->foreign('service_id')->references('id')->on('services'); }); diff --git a/database/migrations/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php b/database/migrations/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php index a3f5d1a50..d4f1dab11 100644 --- a/database/migrations/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php +++ b/database/migrations/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php @@ -12,7 +12,9 @@ return new class extends Migration public function up(): void { Schema::table('packs', function (Blueprint $table) { - $table->dropForeign(['option_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['option_id']); + } $table->foreign('option_id')->references('id')->on('service_options')->onDelete('cascade'); }); @@ -24,8 +26,9 @@ return new class extends Migration public function down(): void { Schema::table('packs', function (Blueprint $table) { - $table->dropForeign(['option_id']); - + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['option_id']); + } $table->foreign('option_id')->references('id')->on('service_options'); }); } diff --git a/database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php b/database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php index de17187c1..effef871e 100644 --- a/database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php +++ b/database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php @@ -12,7 +12,9 @@ return new class extends Migration public function up(): void { Schema::table('service_variables', function (Blueprint $table) { - $table->dropForeign(['option_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['option_id']); + } $table->foreign('option_id')->references('id')->on('service_options')->onDelete('CASCADE'); }); @@ -24,7 +26,9 @@ return new class extends Migration public function down(): void { Schema::table('service_variables', function (Blueprint $table) { - $table->dropForeign(['option_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['option_id']); + } $table->foreign('option_id')->references('id')->on('service_options'); }); diff --git a/database/migrations/2017_10_06_214026_ServicesToNestsConversion.php b/database/migrations/2017_10_06_214026_ServicesToNestsConversion.php index ada29a324..496e18d6c 100644 --- a/database/migrations/2017_10_06_214026_ServicesToNestsConversion.php +++ b/database/migrations/2017_10_06_214026_ServicesToNestsConversion.php @@ -1,5 +1,6 @@ dropForeign(['service_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['service_id']); + } $table->renameColumn('service_id', 'nest_id'); $table->foreign('nest_id')->references('id')->on('nests'); }); Schema::table('service_options', function (Blueprint $table) { - $table->dropForeign(['service_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['service_id']); + } $table->renameColumn('service_id', 'nest_id'); $table->foreign('nest_id')->references('id')->on('nests')->onDelete('CASCADE'); @@ -41,14 +46,18 @@ return new class extends Migration Schema::rename('nests', 'services'); Schema::table('servers', function (Blueprint $table) { - $table->dropForeign(['nest_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['nest_id']); + } $table->renameColumn('nest_id', 'service_id'); $table->foreign('service_id')->references('id')->on('services'); }); Schema::table('service_options', function (Blueprint $table) { - $table->dropForeign(['nest_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['nest_id']); + } $table->renameColumn('nest_id', 'service_id'); $table->foreign('service_id')->references('id')->on('services')->onDelete('CASCADE'); diff --git a/database/migrations/2017_10_06_214053_ServiceOptionsToEggsConversion.php b/database/migrations/2017_10_06_214053_ServiceOptionsToEggsConversion.php index 1fde279f8..d49c2fc98 100644 --- a/database/migrations/2017_10_06_214053_ServiceOptionsToEggsConversion.php +++ b/database/migrations/2017_10_06_214053_ServiceOptionsToEggsConversion.php @@ -1,5 +1,6 @@ dropForeign(['config_from']); - $table->dropForeign(['copy_script_from']); - }); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + Schema::table('service_options', function (Blueprint $table) { + $table->dropForeign(['config_from']); + $table->dropForeign(['copy_script_from']); + }); + } Schema::rename('service_options', 'eggs'); Schema::table('packs', function (Blueprint $table) { - $table->dropForeign(['option_id']); - $table->renameColumn('option_id', 'egg_id'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['option_id']); + } + $table->renameColumn('option_id', 'egg_id'); $table->foreign('egg_id')->references('id')->on('eggs')->onDelete('CASCADE'); }); Schema::table('servers', function (Blueprint $table) { - $table->dropForeign(['option_id']); - $table->renameColumn('option_id', 'egg_id'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['option_id']); + } + $table->renameColumn('option_id', 'egg_id'); $table->foreign('egg_id')->references('id')->on('eggs'); }); @@ -39,7 +46,10 @@ return new class extends Migration }); Schema::table('service_variables', function (Blueprint $table) { - $table->dropForeign(['option_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['option_id']); + } + $table->renameColumn('option_id', 'egg_id'); $table->foreign('egg_id')->references('id')->on('eggs')->onDelete('CASCADE'); @@ -55,24 +65,30 @@ return new class extends Migration { Schema::disableForeignKeyConstraints(); - Schema::table('eggs', function (Blueprint $table) { - $table->dropForeign(['config_from']); - $table->dropForeign(['copy_script_from']); - }); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + Schema::table('eggs', function (Blueprint $table) { + $table->dropForeign(['config_from']); + $table->dropForeign(['copy_script_from']); + }); + } Schema::rename('eggs', 'service_options'); Schema::table('packs', function (Blueprint $table) { - $table->dropForeign(['egg_id']); - $table->renameColumn('egg_id', 'option_id'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['egg_id']); + } + $table->renameColumn('egg_id', 'option_id'); $table->foreign('option_id')->references('id')->on('service_options')->onDelete('CASCADE'); }); Schema::table('servers', function (Blueprint $table) { - $table->dropForeign(['egg_id']); - $table->renameColumn('egg_id', 'option_id'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['egg_id']); + } + $table->renameColumn('egg_id', 'option_id'); $table->foreign('option_id')->references('id')->on('service_options'); }); @@ -82,9 +98,11 @@ return new class extends Migration }); Schema::table('service_variables', function (Blueprint $table) { - $table->dropForeign(['egg_id']); - $table->renameColumn('egg_id', 'option_id'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['egg_id']); + } + $table->renameColumn('egg_id', 'option_id'); $table->foreign('option_id')->references('id')->on('options')->onDelete('CASCADE'); }); diff --git a/database/migrations/2017_10_06_215741_ServiceVariablesToEggVariablesConversion.php b/database/migrations/2017_10_06_215741_ServiceVariablesToEggVariablesConversion.php index aa6816984..8b4b0ff37 100644 --- a/database/migrations/2017_10_06_215741_ServiceVariablesToEggVariablesConversion.php +++ b/database/migrations/2017_10_06_215741_ServiceVariablesToEggVariablesConversion.php @@ -1,5 +1,6 @@ dropForeign(['variable_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['variable_id']); + } $table->foreign('variable_id')->references('id')->on('egg_variables')->onDelete('CASCADE'); }); @@ -33,7 +36,9 @@ return new class extends Migration Schema::rename('egg_variables', 'service_variables'); Schema::table('server_variables', function (Blueprint $table) { - $table->dropForeign(['variable_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['variable_id']); + } $table->foreign('variable_id')->references('id')->on('service_variables')->onDelete('CASCADE'); }); diff --git a/database/migrations/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php b/database/migrations/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php index 243171ba2..77a614ea5 100644 --- a/database/migrations/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php +++ b/database/migrations/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php @@ -28,12 +28,19 @@ return new class extends Migration }); }); - Schema::table('api_keys', function (Blueprint $table) { - $table->dropColumn('public'); - $table->string('secret', 32)->change(); - }); + if (Schema::getConnection()->getDriverName() === 'sqlite') { + Schema::table('api_keys', function (Blueprint $table) { + $table->dropColumn('public'); + $table->char('secret', 32)->change(); + $table->renameColumn('secret', 'token'); + $table->string('token', 32)->unique()->change(); + }); + } + + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + DB::statement('ALTER TABLE `api_keys` CHANGE `secret` `token` CHAR(32) NOT NULL, ADD UNIQUE INDEX `api_keys_token_unique` (`token`(32))'); + } - DB::statement('ALTER TABLE `api_keys` CHANGE `secret` `token` CHAR(32) NOT NULL, ADD UNIQUE INDEX `api_keys_token_unique` (`token`(32))'); } /** diff --git a/database/migrations/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php b/database/migrations/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php index 1f166a997..ccb4925d4 100644 --- a/database/migrations/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php +++ b/database/migrations/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php @@ -12,7 +12,9 @@ return new class extends Migration public function up(): void { Schema::table('allocations', function (Blueprint $table) { - $table->dropForeign(['node_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['node_id']); + } $table->foreign('node_id')->references('id')->on('nodes')->onDelete('cascade'); }); @@ -24,7 +26,9 @@ return new class extends Migration public function down(): void { Schema::table('allocations', function (Blueprint $table) { - $table->dropForeign(['node_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['node_id']); + } $table->foreign('node_id')->references('id')->on('nodes'); }); diff --git a/database/migrations/2017_12_12_220426_MigrateSettingsTableToNewFormat.php b/database/migrations/2017_12_12_220426_MigrateSettingsTableToNewFormat.php index 7e916861c..3f9d96f95 100644 --- a/database/migrations/2017_12_12_220426_MigrateSettingsTableToNewFormat.php +++ b/database/migrations/2017_12_12_220426_MigrateSettingsTableToNewFormat.php @@ -1,6 +1,5 @@ truncate(); - Schema::table('settings', function (Blueprint $table) { - $table->increments('id')->first(); + Schema::dropIfExists('settings'); + Schema::create('settings', function (Blueprint $table) { + $table->increments('id'); + $table->string('key'); + $table->text('value'); }); } diff --git a/database/migrations/2018_01_13_145209_AddLastUsedAtColumn.php b/database/migrations/2018_01_13_145209_AddLastUsedAtColumn.php index 0d6a43960..2227864a7 100644 --- a/database/migrations/2018_01_13_145209_AddLastUsedAtColumn.php +++ b/database/migrations/2018_01_13_145209_AddLastUsedAtColumn.php @@ -16,7 +16,9 @@ return new class extends Migration $table->timestamp('last_used_at')->after('memo')->nullable(); $table->dropColumn('expires_at'); - $table->dropForeign(['user_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['user_id']); + } }); Schema::table('api_keys', function (Blueprint $table) { @@ -32,7 +34,10 @@ return new class extends Migration Schema::table('api_keys', function (Blueprint $table) { $table->timestamp('expires_at')->after('memo')->nullable(); $table->dropColumn('last_used_at', 'key_type'); - $table->dropForeign(['user_id']); + + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign(['user_id']); + } }); Schema::table('api_keys', function (Blueprint $table) { diff --git a/database/migrations/2020_04_03_230614_create_backups_table.php b/database/migrations/2020_04_03_230614_create_backups_table.php index 556ebc490..b45e43f63 100644 --- a/database/migrations/2020_04_03_230614_create_backups_table.php +++ b/database/migrations/2020_04_03_230614_create_backups_table.php @@ -1,6 +1,5 @@ TABLE_NAME, $result->TABLE_NAME . '_plugin_bak'); - } - Schema::create('backups', function (Blueprint $table) { $table->bigIncrements('id'); $table->unsignedInteger('server_id'); diff --git a/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php b/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php index c7aec7ed3..a8cadd6fa 100644 --- a/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php +++ b/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php @@ -1,6 +1,5 @@ unsignedInteger('backup_limit')->default(0)->change(); - }); - } else { - Schema::table('servers', function (Blueprint $table) { - $table->unsignedInteger('backup_limit')->default(0)->after('database_limit'); - }); - } + Schema::table('servers', function (Blueprint $table) { + $table->unsignedInteger('backup_limit')->default(0)->after('database_limit'); + }); } /** diff --git a/database/migrations/2020_08_23_175331_modify_checksums_column_for_backups.php b/database/migrations/2020_08_23_175331_modify_checksums_column_for_backups.php index 31e733fd1..1fa177162 100644 --- a/database/migrations/2020_08_23_175331_modify_checksums_column_for_backups.php +++ b/database/migrations/2020_08_23_175331_modify_checksums_column_for_backups.php @@ -15,10 +15,6 @@ return new class extends Migration Schema::table('backups', function (Blueprint $table) { $table->renameColumn('sha256_hash', 'checksum'); }); - - Schema::table('backups', function (Blueprint $table) { - DB::update('UPDATE backups SET checksum = CONCAT(\'sha256:\', checksum)'); - }); } /** @@ -29,9 +25,5 @@ return new class extends Migration Schema::table('backups', function (Blueprint $table) { $table->renameColumn('checksum', 'sha256_hash'); }); - - Schema::table('backups', function (Blueprint $table) { - DB::update('UPDATE backups SET sha256_hash = SUBSTRING(sha256_hash, 8)'); - }); } }; 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 39f048b37..cc2695edd 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,7 +12,10 @@ return new class extends Migration public function up(): void { Schema::table('servers', function (Blueprint $table) { - $table->dropForeign(['pack_id']); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $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 2d665d3e3..cc95a5f8e 100644 --- a/database/migrations/2024_03_12_154408_remove_nests_table.php +++ b/database/migrations/2024_03_12_154408_remove_nests_table.php @@ -28,12 +28,16 @@ return new class extends Migration } Schema::table('eggs', function (Blueprint $table) { - $table->dropForeign('service_options_nest_id_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('service_options_nest_id_foreign'); + } $table->dropColumn('nest_id'); }); Schema::table('servers', function (Blueprint $table) { - $table->dropForeign('servers_nest_id_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('servers_nest_id_foreign'); + } $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 7c72d7617..f06ded66f 100644 --- a/database/migrations/2024_03_14_055537_remove_locations_table.php +++ b/database/migrations/2024_03_14_055537_remove_locations_table.php @@ -27,7 +27,10 @@ return new class extends Migration } Schema::table('nodes', function (Blueprint $table) { - $table->dropForeign('nodes_location_id_foreign'); + if (Schema::getConnection()->getDriverName() !== 'sqlite') { + $table->dropForeign('nodes_location_id_foreign'); + } + $table->dropColumn('location_id'); });