feat:영업담당자 User 통합을 위한 마이그레이션 추가
- users 테이블에 parent_id, approval_status, approved_by, approved_at, rejection_reason 컬럼 추가 - sales_manager_documents 테이블 생성 (멀티파일 업로드) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?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->unsignedBigInteger('parent_id')->nullable()->after('is_super_admin');
|
||||
$table->foreign('parent_id')->references('id')->on('users')->onDelete('set null');
|
||||
|
||||
// 승인 상태: pending(대기), approved(승인), rejected(반려)
|
||||
$table->string('approval_status', 20)->default('approved')->after('parent_id');
|
||||
|
||||
// 승인 관련 정보
|
||||
$table->unsignedBigInteger('approved_by')->nullable()->after('approval_status');
|
||||
$table->timestamp('approved_at')->nullable()->after('approved_by');
|
||||
$table->text('rejection_reason')->nullable()->after('approved_at');
|
||||
|
||||
// 인덱스
|
||||
$table->index('parent_id');
|
||||
$table->index('approval_status');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropForeign(['parent_id']);
|
||||
$table->dropIndex(['parent_id']);
|
||||
$table->dropIndex(['approval_status']);
|
||||
|
||||
$table->dropColumn([
|
||||
'parent_id',
|
||||
'approval_status',
|
||||
'approved_by',
|
||||
'approved_at',
|
||||
'rejection_reason',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
<?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('sales_manager_documents', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('tenant_id');
|
||||
$table->unsignedBigInteger('user_id');
|
||||
|
||||
// 파일 정보
|
||||
$table->string('file_path', 500);
|
||||
$table->string('original_name', 255);
|
||||
$table->string('stored_name', 255);
|
||||
$table->string('mime_type', 100)->nullable();
|
||||
$table->unsignedBigInteger('file_size')->default(0);
|
||||
|
||||
// 문서 타입: id_card(신분증), business_license(사업자등록증), contract(계약서), other(기타)
|
||||
$table->string('document_type', 50)->default('other');
|
||||
$table->string('description', 500)->nullable();
|
||||
|
||||
// 메타 정보
|
||||
$table->unsignedBigInteger('uploaded_by')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
||||
|
||||
// 외래키 및 인덱스
|
||||
$table->foreign('tenant_id')->references('id')->on('tenants')->onDelete('cascade');
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreign('uploaded_by')->references('id')->on('users')->onDelete('set null');
|
||||
|
||||
$table->index(['tenant_id', 'user_id']);
|
||||
$table->index('document_type');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sales_manager_documents');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user