瀏覽代碼

Fix parental_controls migration

Daniel Supernault 1 年之前
父節點
當前提交
8a9a7c0e47
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      database/migrations/2024_01_09_052419_create_parental_controls_table.php

+ 6 - 2
database/migrations/2024_01_09_052419_create_parental_controls_table.php

@@ -28,7 +28,7 @@ return new class extends Migration
             $schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
             $indexesFound  = $schemaManager->listTableIndexes('user_roles');
             if (array_key_exists('user_roles_profile_id_unique', $indexesFound)) {
-                $table->dropIndex('user_roles_profile_id_unique');
+                $table->dropUnique('user_roles_profile_id_unique');
             }
             $table->unsignedBigInteger('profile_id')->unique()->nullable()->index()->change();
         });
@@ -42,7 +42,11 @@ return new class extends Migration
         Schema::dropIfExists('parental_controls');
 
         Schema::table('user_roles', function (Blueprint $table) {
-            $table->dropIndex('user_roles_profile_id_unique');
+            $schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
+            $indexesFound  = $schemaManager->listTableIndexes('user_roles');
+            if (array_key_exists('user_roles_profile_id_unique', $indexesFound)) {
+                $table->dropUnique('user_roles_profile_id_unique');
+            }
             $table->unsignedBigInteger('profile_id')->unique()->index()->change();
         });
     }