diff --git a/database/migrations/2026_09_07_071046_add_deleted_at_profile_idindex_to_notifications_table.php b/database/migrations/2026_09_07_071046_add_deleted_at_profile_idindex_to_notifications_table.php index 656329ddc..ec4e33efd 100644 --- a/database/migrations/2026_09_07_071046_add_deleted_at_profile_idindex_to_notifications_table.php +++ b/database/migrations/2026_09_07_071046_add_deleted_at_profile_idindex_to_notifications_table.php @@ -1,39 +1,59 @@ columns) + ->map(fn ($column) => "`{$column}`") + ->implode(', '); + + DB::statement(" + ALTER TABLE `{$this->table}` + ADD INDEX `{$this->index}` ({$columns}), + ALGORITHM=INPLACE, + LOCK=NONE + "); + return; } - DB::statement(' - ALTER TABLE `notifications` - ADD INDEX `notifications_profile_deleted_id_index` - (`profile_id`, `deleted_at`, `id`), - ALGORITHM=INPLACE, - LOCK=NONE - '); + Schema::table($this->table, function (Blueprint $table) { + $table->index($this->columns, $this->index); + }); } public function down(): void { - if (DB::getDriverName() === 'sqlite') { + if (in_array(DB::getDriverName(), ['mysql', 'mariadb'], true)) { + DB::statement(" + ALTER TABLE `{$this->table}` + DROP INDEX `{$this->index}`, + ALGORITHM=INPLACE, + LOCK=NONE + "); + return; } - DB::statement(' - ALTER TABLE `notifications` - DROP INDEX `notifications_profile_deleted_id_index`, - ALGORITHM=INPLACE, - LOCK=NONE - '); + Schema::table($this->table, function (Blueprint $table) { + $table->dropIndex($this->index); + }); } }; diff --git a/database/migrations/2026_09_07_080905_add_media_delete_index.php b/database/migrations/2026_09_07_080905_add_media_delete_index.php index 85365329b..4a10e8fca 100644 --- a/database/migrations/2026_09_07_080905_add_media_delete_index.php +++ b/database/migrations/2026_09_07_080905_add_media_delete_index.php @@ -1,36 +1,59 @@ columns) + ->map(fn ($column) => "`{$column}`") + ->implode(', '); + + DB::statement(" + ALTER TABLE `{$this->table}` + ADD INDEX `{$this->index}` ({$columns}), + ALGORITHM=INPLACE, + LOCK=NONE + "); + return; } - DB::statement(' - ALTER TABLE `media` - ADD INDEX `media_unoptimized_recent_index` - (`processed_at`, `remote_url`, `deleted_at`, `created_at`, `id`), - ALGORITHM=INPLACE, - LOCK=NONE - '); + Schema::table($this->table, function (Blueprint $table) { + $table->index($this->columns, $this->index); + }); } public function down(): void { - if (DB::getDriverName() === 'sqlite') { + if (in_array(DB::getDriverName(), ['mysql', 'mariadb'], true)) { + DB::statement(" + ALTER TABLE `{$this->table}` + DROP INDEX `{$this->index}`, + ALGORITHM=INPLACE, + LOCK=NONE + "); + return; } - DB::statement(' - ALTER TABLE `media` - DROP INDEX `media_unoptimized_recent_index`, - ALGORITHM=INPLACE, - LOCK=NONE - '); + Schema::table($this->table, function (Blueprint $table) { + $table->dropIndex($this->index); + }); } }; diff --git a/database/migrations/2026_09_10_000000_add_user_id_size_index_to_media_table.php b/database/migrations/2026_09_10_000000_add_user_id_size_index_to_media_table.php index 8b03d359b..5f7af529d 100644 --- a/database/migrations/2026_09_10_000000_add_user_id_size_index_to_media_table.php +++ b/database/migrations/2026_09_10_000000_add_user_id_size_index_to_media_table.php @@ -1,44 +1,65 @@ columns) + ->map(fn ($column) => "`{$column}`") + ->implode(', '); + + DB::statement(" + ALTER TABLE `{$this->table}` + ADD INDEX `{$this->index}` ({$columns}), + ALGORITHM=INPLACE, + LOCK=NONE + "); + return; } - DB::statement(' - ALTER TABLE `media` - ADD INDEX `media_user_id_size_index` (`user_id`, `size`), - ALGORITHM=INPLACE, - LOCK=NONE - '); + Schema::table($this->table, function (Blueprint $table) { + $table->index($this->columns, $this->index); + }); } public function down(): void { - if (DB::getDriverName() === 'sqlite') { + if (in_array(DB::getDriverName(), ['mysql', 'mariadb'], true)) { + DB::statement(" + ALTER TABLE `{$this->table}` + DROP INDEX `{$this->index}`, + ALGORITHM=INPLACE, + LOCK=NONE + "); + return; } - DB::statement(' - ALTER TABLE `media` - DROP INDEX `media_user_id_size_index`, - ALGORITHM=INPLACE, - LOCK=NONE - '); + Schema::table($this->table, function (Blueprint $table) { + $table->dropIndex($this->index); + }); } };