feat: 계좌관리 추가

This commit is contained in:
pro
2026-01-20 20:43:38 +09:00
parent 7246ac003f
commit 0ae3c5aa07
1533 changed files with 5791 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,88 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 작업지시 하위 테이블에 tenant_id 컬럼 추가
* - work_order_items
* - work_order_bending_details
* - work_order_issues
*
* 기존 데이터는 work_orders 테이블의 tenant_id를 참조하여 업데이트
*/
public function up(): void
{
// 1. work_order_items
Schema::table('work_order_items', function (Blueprint $table) {
$table->unsignedBigInteger('tenant_id')->nullable()->after('id')->comment('테넌트ID');
$table->index('tenant_id', 'idx_work_order_items_tenant');
});
// 기존 데이터 업데이트
DB::statement('
UPDATE work_order_items wi
JOIN work_orders wo ON wi.work_order_id = wo.id
SET wi.tenant_id = wo.tenant_id
');
// nullable 제거
Schema::table('work_order_items', function (Blueprint $table) {
$table->unsignedBigInteger('tenant_id')->nullable(false)->change();
});
// 2. work_order_bending_details
Schema::table('work_order_bending_details', function (Blueprint $table) {
$table->unsignedBigInteger('tenant_id')->nullable()->after('id')->comment('테넌트ID');
$table->index('tenant_id', 'idx_work_order_bending_details_tenant');
});
DB::statement('
UPDATE work_order_bending_details wbd
JOIN work_orders wo ON wbd.work_order_id = wo.id
SET wbd.tenant_id = wo.tenant_id
');
Schema::table('work_order_bending_details', function (Blueprint $table) {
$table->unsignedBigInteger('tenant_id')->nullable(false)->change();
});
// 3. work_order_issues
Schema::table('work_order_issues', function (Blueprint $table) {
$table->unsignedBigInteger('tenant_id')->nullable()->after('id')->comment('테넌트ID');
$table->index('tenant_id', 'idx_work_order_issues_tenant');
});
DB::statement('
UPDATE work_order_issues woi
JOIN work_orders wo ON woi.work_order_id = wo.id
SET woi.tenant_id = wo.tenant_id
');
Schema::table('work_order_issues', function (Blueprint $table) {
$table->unsignedBigInteger('tenant_id')->nullable(false)->change();
});
}
public function down(): void
{
Schema::table('work_order_items', function (Blueprint $table) {
$table->dropIndex('idx_work_order_items_tenant');
$table->dropColumn('tenant_id');
});
Schema::table('work_order_bending_details', function (Blueprint $table) {
$table->dropIndex('idx_work_order_bending_details_tenant');
$table->dropColumn('tenant_id');
});
Schema::table('work_order_issues', function (Blueprint $table) {
$table->dropIndex('idx_work_order_issues_tenant');
$table->dropColumn('tenant_id');
});
}
};

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 작업지시 담당자 피벗 테이블 (Work Order Assignees)
* - 다중 담당자 지원
* - 주 담당자 구분 (is_primary)
*/
public function up(): void
{
Schema::create('work_order_assignees', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('tenant_id')->comment('테넌트ID');
$table->unsignedBigInteger('work_order_id')->comment('작업지시ID');
$table->unsignedBigInteger('user_id')->comment('담당자ID');
$table->boolean('is_primary')->default(false)->comment('주담당자 여부');
$table->timestamps();
// Indexes
$table->unique(['work_order_id', 'user_id'], 'uq_work_order_assignees');
$table->index(['tenant_id', 'work_order_id'], 'idx_wo_assignees_tenant_wo');
$table->index(['tenant_id', 'user_id'], 'idx_wo_assignees_tenant_user');
// Foreign keys
$table->foreign('work_order_id')
->references('id')
->on('work_orders')
->onDelete('cascade');
});
}
public function down(): void
{
Schema::dropIfExists('work_order_assignees');
}
};

Some files were not shown because too many files have changed in this diff Show More