feat: 데모 URL 관리 시스템 마이그레이션 및 시더 추가

- users 테이블에 role, is_active 필드 추가
- prospects 테이블 생성 (업체 정보)
- demo_links 테이블 생성 (토큰 관리)
- DemoSystemSeeder 추가 (Ops/Sales 계정, 샘플 데이터)
This commit is contained in:
2025-10-14 14:28:58 +09:00
parent c5ea6d189a
commit 8d2b6fc6e5
4 changed files with 174 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->enum('role', ['sales', 'ops'])->default('sales')->after('email');
$table->boolean('is_active')->default(true)->after('role');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['role', 'is_active']);
});
}
};

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('prospects', function (Blueprint $table) {
$table->id();
$table->foreignId('sales_user_id')->constrained('users')->onDelete('cascade');
$table->string('company_name', 100);
$table->string('contact_person', 100)->nullable();
$table->string('email', 100)->nullable();
$table->string('phone', 20)->nullable();
$table->text('notes')->nullable();
$table->timestamps();
$table->index('sales_user_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('prospects');
}
};

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('demo_links', function (Blueprint $table) {
$table->id();
$table->foreignId('prospect_id')->constrained('prospects')->onDelete('cascade');
$table->foreignId('created_by')->constrained('users')->onDelete('cascade');
$table->string('token', 64)->unique();
$table->enum('status', ['active', 'expired', 'revoked'])->default('active');
$table->timestamp('expires_at');
$table->unsignedInteger('visit_count')->default(0);
$table->timestamps();
$table->index(['token', 'status']);
$table->index('prospect_id');
$table->index('created_by');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('demo_links');
}
};

View File

@@ -0,0 +1,73 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Shared\Models\Members\User;
use Shared\Models\Sales\Prospect;
use Shared\Models\Sales\DemoLink;
use Illuminate\Support\Facades\Hash;
class DemoSystemSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// 1. Ops 계정 생성
$ops = User::create([
'user_id' => 'OPS001',
'name' => 'Ops Admin',
'email' => 'ops@sam.kr',
'password' => Hash::make('password'),
'role' => 'ops',
'is_active' => true,
]);
echo "✅ Ops 계정 생성: ops@sam.kr / password\n";
// 2. Sales 계정 생성
$sales = User::create([
'user_id' => 'SALES001',
'name' => 'Sales User',
'email' => 'sales@sam.kr',
'password' => Hash::make('password'),
'role' => 'sales',
'is_active' => true,
]);
echo "✅ Sales 계정 생성: sales@sam.kr / password\n";
// 3. 샘플 업체 생성
$prospect = Prospect::create([
'sales_user_id' => $sales->id,
'company_name' => '테스트 고객사',
'contact_person' => '홍길동',
'email' => 'test@example.com',
'phone' => '010-1234-5678',
'notes' => 'MVP 테스트용 샘플 업체입니다.',
]);
echo "✅ 샘플 업체 생성: {$prospect->company_name}\n";
// 4. 샘플 데모 링크 생성 (3일 만료)
$demoLink = DemoLink::create([
'prospect_id' => $prospect->id,
'created_by' => $sales->id,
'token' => DemoLink::generateToken(),
'status' => 'active',
'expires_at' => now()->addDays(3),
'visit_count' => 0,
]);
echo "✅ 샘플 데모 링크 생성: http://dev.sam.kr/d/{$demoLink->token}\n";
echo "\n";
echo "🎉 데모 시스템 시더 완료!\n";
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
echo "Ops 로그인: ops@sam.kr / password\n";
echo "Sales 로그인: sales@sam.kr / password\n";
echo "데모 링크: http://dev.sam.kr/d/{$demoLink->token}\n";
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
}
}