feat:영업권(명함등록) 테이블 마이그레이션 추가

- tenant_prospects 테이블 생성
- 영업권 2개월 유효, 1개월 쿨다운 정책 지원
- 테넌트 전환 추적 기능 포함

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
pro
2026-01-27 22:39:30 +09:00
parent 5de77e3b35
commit 9182cbc1b3

View File

@@ -0,0 +1,75 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* 영업파트너 영업권(명함등록) 테이블
*
* 영업 프로세스:
* 1. 영업파트너가 명함 등록 (status = 'active')
* 2. 2개월간 영업권 유효 (expires_at)
* 3. 계약 성사 시 테넌트 전환 (status = 'converted', tenant_id 연결)
* 4. 미성사/만료 시 (status = 'expired')
* 5. 만료 후 1개월 쿨다운 (cooldown_ends_at) 이후 재등록 가능
*/
return new class extends Migration
{
public function up(): void
{
Schema::create('tenant_prospects', function (Blueprint $table) {
$table->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');
}
};