From 60a1d753fd0d3c38535c92dc45ad02e0654241df Mon Sep 17 00:00:00 2001 From: pro Date: Fri, 30 Jan 2026 15:08:38 +0900 Subject: [PATCH] =?UTF-8?q?feat:sales=5Fscenario=5Fchecklists=20=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EB=B8=94=20=EB=88=84=EB=9D=BD=20=EC=BB=AC=EB=9F=BC=20?= =?UTF-8?q?=EB=A7=88=EC=9D=B4=EA=B7=B8=EB=A0=88=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- ...mns_to_sales_scenario_checklists_table.php | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 database/migrations/2026_01_30_150000_add_missing_columns_to_sales_scenario_checklists_table.php diff --git a/database/migrations/2026_01_30_150000_add_missing_columns_to_sales_scenario_checklists_table.php b/database/migrations/2026_01_30_150000_add_missing_columns_to_sales_scenario_checklists_table.php new file mode 100644 index 0000000..fd081f3 --- /dev/null +++ b/database/migrations/2026_01_30_150000_add_missing_columns_to_sales_scenario_checklists_table.php @@ -0,0 +1,107 @@ +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', + ]); + }); + } +};