fix:Laravel 12 호환 - Doctrine DBAL 대신 DB::select 사용

- getDoctrineSchemaManager() 제거 (Laravel 12에서 미지원)
- 인덱스 존재 여부 확인을 SHOW INDEX 쿼리로 변경

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
pro
2026-01-30 15:17:16 +09:00
parent 73dd6595d0
commit d412ae45b7

View File

@@ -3,6 +3,7 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
@@ -62,26 +63,27 @@ public function up(): void
});
// 인덱스 추가 (이미 존재하면 무시)
Schema::table('sales_scenario_checklists', function (Blueprint $table) {
$sm = Schema::getConnection()->getDoctrineSchemaManager();
$indexes = $sm->listTableIndexes('sales_scenario_checklists');
// UNIQUE KEY 추가
if (!isset($indexes['sales_scenario_checkpoint_unique'])) {
// UNIQUE KEY 추가
$uniqueExists = DB::select("SHOW INDEX FROM sales_scenario_checklists WHERE Key_name = 'sales_scenario_checkpoint_unique'");
if (empty($uniqueExists)) {
Schema::table('sales_scenario_checklists', function (Blueprint $table) {
$table->unique(
['tenant_id', 'scenario_type', 'step_id', 'checkpoint_id'],
'sales_scenario_checkpoint_unique'
);
}
});
}
// INDEX 추가
if (!isset($indexes['sales_scenario_checklists_tenant_id_scenario_type_index'])) {
// INDEX 추가
$indexExists = DB::select("SHOW INDEX FROM sales_scenario_checklists WHERE Key_name = 'sales_scenario_checklists_tenant_id_scenario_type_index'");
if (empty($indexExists)) {
Schema::table('sales_scenario_checklists', function (Blueprint $table) {
$table->index(
['tenant_id', 'scenario_type'],
'sales_scenario_checklists_tenant_id_scenario_type_index'
);
}
});
});
}
}
/**