diff --git a/database/migrations/2026_01_31_200000_add_tenant_prospect_id_to_sales_tables.php b/database/migrations/2026_01_31_200000_add_tenant_prospect_id_to_sales_tables.php new file mode 100644 index 0000000..4c7a5ac --- /dev/null +++ b/database/migrations/2026_01_31_200000_add_tenant_prospect_id_to_sales_tables.php @@ -0,0 +1,51 @@ +unsignedBigInteger('tenant_prospect_id')->nullable()->after('tenant_id'); + $table->foreign('tenant_prospect_id')->references('id')->on('tenant_prospects')->onDelete('cascade'); + + // tenant_id를 nullable로 변경 (가망고객 단계에서는 tenant 없음) + $table->unsignedBigInteger('tenant_id')->nullable()->change(); + }); + + // sales_scenario_checklists 테이블에 tenant_prospect_id 추가 + Schema::table('sales_scenario_checklists', function (Blueprint $table) { + $table->unsignedBigInteger('tenant_prospect_id')->nullable()->after('tenant_id'); + $table->foreign('tenant_prospect_id')->references('id')->on('tenant_prospects')->onDelete('cascade'); + + // tenant_id를 nullable로 변경 + $table->unsignedBigInteger('tenant_id')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('sales_scenario_checklists', function (Blueprint $table) { + $table->dropForeign(['tenant_prospect_id']); + $table->dropColumn('tenant_prospect_id'); + }); + + Schema::table('sales_tenant_managements', function (Blueprint $table) { + $table->dropForeign(['tenant_prospect_id']); + $table->dropColumn('tenant_prospect_id'); + }); + } +};