feat:sales_scenario_checklists 테이블 누락 컬럼 마이그레이션 추가
- scenario_type (ENUM: sales/manager) - checkpoint_id (VARCHAR 50) - checked_at (TIMESTAMP) - checked_by (BIGINT UNSIGNED) - memo (TEXT) - UNIQUE KEY, INDEX 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('sales_scenario_checklists', function (Blueprint $table) {
|
||||
// scenario_type 컬럼 추가 (tenant_id 다음에)
|
||||
if (!Schema::hasColumn('sales_scenario_checklists', 'scenario_type')) {
|
||||
$table->enum('scenario_type', ['sales', 'manager'])
|
||||
->default('sales')
|
||||
->comment('시나리오 유형')
|
||||
->after('tenant_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('sales_scenario_checklists', function (Blueprint $table) {
|
||||
// checkpoint_id 컬럼 추가 (step_id 다음에)
|
||||
if (!Schema::hasColumn('sales_scenario_checklists', 'checkpoint_id')) {
|
||||
$table->string('checkpoint_id', 50)
|
||||
->nullable()
|
||||
->comment('체크포인트 ID')
|
||||
->after('step_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('sales_scenario_checklists', function (Blueprint $table) {
|
||||
// checked_at 컬럼 추가 (is_checked 다음에)
|
||||
if (!Schema::hasColumn('sales_scenario_checklists', 'checked_at')) {
|
||||
$table->timestamp('checked_at')
|
||||
->nullable()
|
||||
->comment('체크 일시')
|
||||
->after('is_checked');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('sales_scenario_checklists', function (Blueprint $table) {
|
||||
// checked_by 컬럼 추가 (checked_at 다음에)
|
||||
if (!Schema::hasColumn('sales_scenario_checklists', 'checked_by')) {
|
||||
$table->unsignedBigInteger('checked_by')
|
||||
->nullable()
|
||||
->comment('체크한 사용자 ID')
|
||||
->after('checked_at');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('sales_scenario_checklists', function (Blueprint $table) {
|
||||
// memo 컬럼 추가 (checked_by 다음에)
|
||||
if (!Schema::hasColumn('sales_scenario_checklists', 'memo')) {
|
||||
$table->text('memo')
|
||||
->nullable()
|
||||
->comment('메모')
|
||||
->after('checked_by');
|
||||
}
|
||||
});
|
||||
|
||||
// 인덱스 추가 (이미 존재하면 무시)
|
||||
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'])) {
|
||||
$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'])) {
|
||||
$table->index(
|
||||
['tenant_id', 'scenario_type'],
|
||||
'sales_scenario_checklists_tenant_id_scenario_type_index'
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('sales_scenario_checklists', function (Blueprint $table) {
|
||||
// 인덱스 삭제
|
||||
$table->dropIndex('sales_scenario_checklists_tenant_id_scenario_type_index');
|
||||
$table->dropUnique('sales_scenario_checkpoint_unique');
|
||||
|
||||
// 컬럼 삭제
|
||||
$table->dropColumn([
|
||||
'scenario_type',
|
||||
'checkpoint_id',
|
||||
'checked_at',
|
||||
'checked_by',
|
||||
'memo',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user