From 4d1180b1c11b880c515f0154eb4a461e14a5eb38 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 1 Jul 2024 02:39:42 -0600 Subject: [PATCH] Fix migrations --- ...te_status_table_change_caption_to_text.php | 7 ------ ...043935_add_snowflakeids_to_users_table.php | 5 ----- ...16_184644_add_layout_to_profiles_table.php | 5 ----- ...add_snowflake_ids_to_collections_table.php | 5 ----- ...12_074612_add_unique_to_statuses_table.php | 5 ----- ...032757_add_object_id_to_statuses_table.php | 5 ----- ...2019_12_25_042317_update_stories_table.php | 4 ---- ...ompose_settings_to_user_settings_table.php | 10 ++++----- ...te_stories_table_fix_expires_at_column.php | 22 +++++++++---------- ...old_compound_index_from_statuses_table.php | 5 +++-- ...table_remove_cdn_url_unique_constraint.php | 6 ++--- ..._052419_create_parental_controls_table.php | 12 +++++----- ..._add_index_to_nodeinfo_last_fetched_at.php | 12 +++++----- ...232204_add_url_index_to_statuses_table.php | 12 +++++----- 14 files changed, 39 insertions(+), 76 deletions(-) diff --git a/database/migrations/2018_08_12_042648_update_status_table_change_caption_to_text.php b/database/migrations/2018_08_12_042648_update_status_table_change_caption_to_text.php index 34d67e8c4..28484b42c 100644 --- a/database/migrations/2018_08_12_042648_update_status_table_change_caption_to_text.php +++ b/database/migrations/2018_08_12_042648_update_status_table_change_caption_to_text.php @@ -5,13 +5,6 @@ use Illuminate\Support\Facades\Schema; class UpdateStatusTableChangeCaptionToText extends Migration { - public function __construct() - { - DB::getDoctrineSchemaManager() - ->getDatabasePlatform() - ->registerDoctrineTypeMapping('enum', 'string'); - } - /** * Run the migrations. * diff --git a/database/migrations/2019_03_12_043935_add_snowflakeids_to_users_table.php b/database/migrations/2019_03_12_043935_add_snowflakeids_to_users_table.php index 3815090ab..e5d32f2db 100644 --- a/database/migrations/2019_03_12_043935_add_snowflakeids_to_users_table.php +++ b/database/migrations/2019_03_12_043935_add_snowflakeids_to_users_table.php @@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration; class AddSnowflakeidsToUsersTable extends Migration { - public function __construct() - { - DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); - } - /** * Run the migrations. * diff --git a/database/migrations/2019_04_16_184644_add_layout_to_profiles_table.php b/database/migrations/2019_04_16_184644_add_layout_to_profiles_table.php index ed47eb17c..17328dea5 100644 --- a/database/migrations/2019_04_16_184644_add_layout_to_profiles_table.php +++ b/database/migrations/2019_04_16_184644_add_layout_to_profiles_table.php @@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration; class AddLayoutToProfilesTable extends Migration { - public function __construct() - { - DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); - } - /** * Run the migrations. * diff --git a/database/migrations/2019_04_25_200411_add_snowflake_ids_to_collections_table.php b/database/migrations/2019_04_25_200411_add_snowflake_ids_to_collections_table.php index 10392de1f..c7cab9c5b 100644 --- a/database/migrations/2019_04_25_200411_add_snowflake_ids_to_collections_table.php +++ b/database/migrations/2019_04_25_200411_add_snowflake_ids_to_collections_table.php @@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration; class AddSnowflakeIdsToCollectionsTable extends Migration { - public function __construct() - { - DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); - } - /** * Run the migrations. * diff --git a/database/migrations/2019_08_12_074612_add_unique_to_statuses_table.php b/database/migrations/2019_08_12_074612_add_unique_to_statuses_table.php index 8d47e6d4f..933ce23af 100644 --- a/database/migrations/2019_08_12_074612_add_unique_to_statuses_table.php +++ b/database/migrations/2019_08_12_074612_add_unique_to_statuses_table.php @@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration; class AddUniqueToStatusesTable extends Migration { - public function __construct() - { - DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); - } - /** * Run the migrations. * diff --git a/database/migrations/2019_09_09_032757_add_object_id_to_statuses_table.php b/database/migrations/2019_09_09_032757_add_object_id_to_statuses_table.php index 3cdf9e25a..1832cdeee 100644 --- a/database/migrations/2019_09_09_032757_add_object_id_to_statuses_table.php +++ b/database/migrations/2019_09_09_032757_add_object_id_to_statuses_table.php @@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration; class AddObjectIdToStatusesTable extends Migration { - public function __construct() - { - DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); - } - /** * Run the migrations. * diff --git a/database/migrations/2019_12_25_042317_update_stories_table.php b/database/migrations/2019_12_25_042317_update_stories_table.php index da778225e..37f63c8ed 100644 --- a/database/migrations/2019_12_25_042317_update_stories_table.php +++ b/database/migrations/2019_12_25_042317_update_stories_table.php @@ -6,10 +6,6 @@ use Illuminate\Support\Facades\Schema; class UpdateStoriesTable extends Migration { - public function __construct() - { - DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); - } /** * Run the migrations. * diff --git a/database/migrations/2021_07_23_062326_add_compose_settings_to_user_settings_table.php b/database/migrations/2021_07_23_062326_add_compose_settings_to_user_settings_table.php index 49a9b2c58..9cbb317c5 100644 --- a/database/migrations/2021_07_23_062326_add_compose_settings_to_user_settings_table.php +++ b/database/migrations/2021_07_23_062326_add_compose_settings_to_user_settings_table.php @@ -41,15 +41,15 @@ class AddComposeSettingsToUserSettingsTable extends Migration Schema::table('media', function (Blueprint $table) { $table->string('caption')->change(); - $schemaManager = Schema::getConnection()->getDoctrineSchemaManager(); - $indexesFound = $schemaManager->listTableIndexes('media'); - if (array_key_exists('media_profile_id_index', $indexesFound)) { + $indexes = Schema::getIndexes('media'); + $indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray(); + if (in_array('media_profile_id_index', $indexesFound)) { $table->dropIndex('media_profile_id_index'); } - if (array_key_exists('media_mime_index', $indexesFound)) { + if (in_array('media_mime_index', $indexesFound)) { $table->dropIndex('media_mime_index'); } - if (array_key_exists('media_license_index', $indexesFound)) { + if (in_array('media_license_index', $indexesFound)) { $table->dropIndex('media_license_index'); } }); diff --git a/database/migrations/2021_08_23_062246_update_stories_table_fix_expires_at_column.php b/database/migrations/2021_08_23_062246_update_stories_table_fix_expires_at_column.php index 61ae60c01..26af256a7 100644 --- a/database/migrations/2021_08_23_062246_update_stories_table_fix_expires_at_column.php +++ b/database/migrations/2021_08_23_062246_update_stories_table_fix_expires_at_column.php @@ -14,12 +14,11 @@ class UpdateStoriesTableFixExpiresAtColumn extends Migration public function up() { Schema::table('stories', function (Blueprint $table) { - $sm = Schema::getConnection()->getDoctrineSchemaManager(); - $doctrineTable = $sm->listTableDetails('stories'); - - if($doctrineTable->hasIndex('stories_expires_at_index')) { - $table->dropIndex('stories_expires_at_index'); - } + $indexes = Schema::getIndexes('stories'); + $indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray(); + if (in_array('stories_expires_at_index', $indexesFound)) { + $table->dropIndex('stories_expires_at_index'); + } $table->timestamp('expires_at')->default(null)->index()->nullable()->change(); $table->boolean('can_reply')->default(true); $table->boolean('can_react')->default(true); @@ -37,12 +36,11 @@ class UpdateStoriesTableFixExpiresAtColumn extends Migration public function down() { Schema::table('stories', function (Blueprint $table) { - $sm = Schema::getConnection()->getDoctrineSchemaManager(); - $doctrineTable = $sm->listTableDetails('stories'); - - if($doctrineTable->hasIndex('stories_expires_at_index')) { - $table->dropIndex('stories_expires_at_index'); - } + $indexes = Schema::getIndexes('stories'); + $indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray(); + if (in_array('stories_expires_at_index', $indexesFound)) { + $table->dropIndex('stories_expires_at_index'); + } $table->timestamp('expires_at')->default(null)->index()->nullable()->change(); $table->dropColumn('can_reply'); $table->dropColumn('can_react'); diff --git a/database/migrations/2022_10_07_055133_remove_old_compound_index_from_statuses_table.php b/database/migrations/2022_10_07_055133_remove_old_compound_index_from_statuses_table.php index ae9b84bbc..e3f943dd8 100644 --- a/database/migrations/2022_10_07_055133_remove_old_compound_index_from_statuses_table.php +++ b/database/migrations/2022_10_07_055133_remove_old_compound_index_from_statuses_table.php @@ -14,8 +14,9 @@ class RemoveOldCompoundIndexFromStatusesTable extends Migration public function up() { Schema::table('statuses', function (Blueprint $table) { - $sc = Schema::getConnection()->getDoctrineSchemaManager(); - if(array_key_exists('statuses_in_reply_to_id_reblog_of_id_index', $sc->listTableIndexes('statuses'))) { + $indexes = Schema::getIndexes('statuses'); + $indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray(); + if (in_array('statuses_in_reply_to_id_reblog_of_id_index', $indexesFound)) { $table->dropIndex('statuses_in_reply_to_id_reblog_of_id_index'); } }); diff --git a/database/migrations/2022_11_30_123940_update_avatars_table_remove_cdn_url_unique_constraint.php b/database/migrations/2022_11_30_123940_update_avatars_table_remove_cdn_url_unique_constraint.php index 423ff1b85..a3767fec0 100644 --- a/database/migrations/2022_11_30_123940_update_avatars_table_remove_cdn_url_unique_constraint.php +++ b/database/migrations/2022_11_30_123940_update_avatars_table_remove_cdn_url_unique_constraint.php @@ -14,9 +14,9 @@ return new class extends Migration public function up() { Schema::table('avatars', function (Blueprint $table) { - $sm = Schema::getConnection()->getDoctrineSchemaManager(); - $indexesFound = $sm->listTableIndexes('avatars'); - if(array_key_exists("avatars_cdn_url_unique", $indexesFound)) { + $indexes = Schema::getIndexes('avatars'); + $indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray(); + if (in_array('avatars_cdn_url_unique', $indexesFound)) { $table->dropUnique('avatars_cdn_url_unique'); } }); diff --git a/database/migrations/2024_01_09_052419_create_parental_controls_table.php b/database/migrations/2024_01_09_052419_create_parental_controls_table.php index 6713e6849..9974c6241 100644 --- a/database/migrations/2024_01_09_052419_create_parental_controls_table.php +++ b/database/migrations/2024_01_09_052419_create_parental_controls_table.php @@ -25,9 +25,9 @@ return new class extends Migration }); Schema::table('user_roles', function (Blueprint $table) { - $schemaManager = Schema::getConnection()->getDoctrineSchemaManager(); - $indexesFound = $schemaManager->listTableIndexes('user_roles'); - if (array_key_exists('user_roles_profile_id_unique', $indexesFound)) { + $indexes = Schema::getIndexes('user_roles'); + $indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray(); + if (in_array('user_roles_profile_id_unique', $indexesFound)) { $table->dropUnique('user_roles_profile_id_unique'); } $table->unsignedBigInteger('profile_id')->unique()->nullable()->index()->change(); @@ -42,9 +42,9 @@ return new class extends Migration Schema::dropIfExists('parental_controls'); Schema::table('user_roles', function (Blueprint $table) { - $schemaManager = Schema::getConnection()->getDoctrineSchemaManager(); - $indexesFound = $schemaManager->listTableIndexes('user_roles'); - if (array_key_exists('user_roles_profile_id_unique', $indexesFound)) { + $indexes = Schema::getIndexes('user_roles'); + $indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray(); + if (in_array('user_roles_profile_id_unique', $indexesFound)) { $table->dropUnique('user_roles_profile_id_unique'); } $table->unsignedBigInteger('profile_id')->unique()->index()->change(); diff --git a/database/migrations/2024_05_31_090555_update_instances_table_add_index_to_nodeinfo_last_fetched_at.php b/database/migrations/2024_05_31_090555_update_instances_table_add_index_to_nodeinfo_last_fetched_at.php index cdd64cfec..a5eb3b921 100644 --- a/database/migrations/2024_05_31_090555_update_instances_table_add_index_to_nodeinfo_last_fetched_at.php +++ b/database/migrations/2024_05_31_090555_update_instances_table_add_index_to_nodeinfo_last_fetched_at.php @@ -12,9 +12,9 @@ return new class extends Migration public function up(): void { Schema::table('instances', function (Blueprint $table) { - $schemaManager = Schema::getConnection()->getDoctrineSchemaManager(); - $indexesFound = $schemaManager->listTableIndexes('instances'); - if (! array_key_exists('instances_nodeinfo_last_fetched_index', $indexesFound)) { + $indexes = Schema::getIndexes('instances'); + $indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray(); + if (!in_array('instances_nodeinfo_last_fetched_index', $indexesFound)) { $table->index('nodeinfo_last_fetched'); } }); @@ -26,9 +26,9 @@ return new class extends Migration public function down(): void { Schema::table('instances', function (Blueprint $table) { - $schemaManager = Schema::getConnection()->getDoctrineSchemaManager(); - $indexesFound = $schemaManager->listTableIndexes('instances'); - if (array_key_exists('instances_nodeinfo_last_fetched_index', $indexesFound)) { + $indexes = Schema::getIndexes('instances'); + $indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray(); + if (in_array('instances_nodeinfo_last_fetched_index', $indexesFound)) { $table->dropIndex('instances_nodeinfo_last_fetched_index'); } }); diff --git a/database/migrations/2024_06_03_232204_add_url_index_to_statuses_table.php b/database/migrations/2024_06_03_232204_add_url_index_to_statuses_table.php index bde5cd9c3..98ce0d5e9 100644 --- a/database/migrations/2024_06_03_232204_add_url_index_to_statuses_table.php +++ b/database/migrations/2024_06_03_232204_add_url_index_to_statuses_table.php @@ -12,9 +12,9 @@ return new class extends Migration public function up(): void { Schema::table('statuses', function (Blueprint $table) { - $schemaManager = Schema::getConnection()->getDoctrineSchemaManager(); - $indexesFound = $schemaManager->listTableIndexes('statuses'); - if (! array_key_exists('statuses_url_index', $indexesFound)) { + $indexes = Schema::getIndexes('statuses'); + $indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray(); + if (!in_array('statuses_url_index', $indexesFound)) { $table->index('url'); } }); @@ -26,9 +26,9 @@ return new class extends Migration public function down(): void { Schema::table('statuses', function (Blueprint $table) { - $schemaManager = Schema::getConnection()->getDoctrineSchemaManager(); - $indexesFound = $schemaManager->listTableIndexes('statuses'); - if (array_key_exists('statuses_url_index', $indexesFound)) { + $indexes = Schema::getIndexes('statuses'); + $indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray(); + if (in_array('statuses_url_index', $indexesFound)) { $table->dropIndex('statuses_url_index'); } });