diff --git a/database/migrations/2026_01_27_200000_add_sales_manager_fields_to_users_table.php b/database/migrations/2026_01_27_200000_add_sales_manager_fields_to_users_table.php new file mode 100644 index 0000000..7a92744 --- /dev/null +++ b/database/migrations/2026_01_27_200000_add_sales_manager_fields_to_users_table.php @@ -0,0 +1,52 @@ +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', + ]); + }); + } +}; diff --git a/database/migrations/2026_01_27_200100_create_sales_manager_documents_table.php b/database/migrations/2026_01_27_200100_create_sales_manager_documents_table.php new file mode 100644 index 0000000..38426ed --- /dev/null +++ b/database/migrations/2026_01_27_200100_create_sales_manager_documents_table.php @@ -0,0 +1,53 @@ +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'); + } +};