diff --git a/database/migrations/2026_01_31_210000_add_tenant_prospect_id_to_sales_consultations.php b/database/migrations/2026_01_31_210000_add_tenant_prospect_id_to_sales_consultations.php new file mode 100644 index 0000000..7cae1db --- /dev/null +++ b/database/migrations/2026_01_31_210000_add_tenant_prospect_id_to_sales_consultations.php @@ -0,0 +1,43 @@ +unsignedBigInteger('tenant_prospect_id') + ->nullable() + ->after('tenant_id') + ->comment('가망고객 ID (테넌트 전환 전)'); + + // tenant_id를 nullable로 변경 (가망고객일 경우 null) + $table->unsignedBigInteger('tenant_id')->nullable()->change(); + + // 인덱스 추가 + $table->index(['tenant_prospect_id', 'scenario_type'], 'consultations_prospect_scenario_idx'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('sales_consultations', function (Blueprint $table) { + $table->dropIndex('consultations_prospect_scenario_idx'); + $table->dropColumn('tenant_prospect_id'); + + // tenant_id를 다시 not nullable로 변경 + $table->unsignedBigInteger('tenant_id')->nullable(false)->change(); + }); + } +};