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