diff --git a/database/migrations/2026_01_27_221000_create_tenant_prospects_table.php b/database/migrations/2026_01_27_221000_create_tenant_prospects_table.php new file mode 100644 index 0000000..3b7a7de --- /dev/null +++ b/database/migrations/2026_01_27_221000_create_tenant_prospects_table.php @@ -0,0 +1,75 @@ +id(); + + // 회사 정보 + $table->string('business_number', 20)->index()->comment('사업자번호 (중복체크 키)'); + $table->string('company_name', 100)->comment('회사명'); + $table->string('ceo_name', 50)->nullable()->comment('대표자명'); + $table->string('contact_phone', 20)->nullable()->comment('연락처'); + $table->string('contact_email', 100)->nullable()->comment('이메일'); + $table->string('address', 500)->nullable()->comment('주소'); + + // 영업파트너 정보 + $table->foreignId('registered_by') + ->constrained('users') + ->cascadeOnDelete() + ->comment('등록한 영업파트너 ID'); + + // 명함 이미지 + $table->string('business_card_path', 500)->nullable()->comment('명함 이미지 경로'); + + // 영업권 상태 + $table->string('status', 20)->default('active')->index()->comment('active, expired, converted'); + $table->timestamp('registered_at')->useCurrent()->comment('등록일'); + $table->timestamp('expires_at')->comment('만료일 (등록일 + 2개월)'); + $table->timestamp('cooldown_ends_at')->comment('쿨다운 종료일 (만료일 + 1개월)'); + + // 테넌트 전환 정보 + $table->foreignId('tenant_id') + ->nullable() + ->constrained('tenants') + ->nullOnDelete() + ->comment('전환된 테넌트 ID'); + $table->timestamp('converted_at')->nullable()->comment('테넌트 전환일'); + $table->foreignId('converted_by') + ->nullable() + ->constrained('users') + ->nullOnDelete() + ->comment('전환 처리자 ID'); + + // 메모 + $table->text('memo')->nullable()->comment('메모'); + + $table->timestamps(); + $table->softDeletes(); + + // 복합 인덱스: 사업자번호 + 상태 (중복 체크용) + $table->index(['business_number', 'status']); + }); + } + + public function down(): void + { + Schema::dropIfExists('tenant_prospects'); + } +};