Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
2026-01-20 21:01:25 +09:00
32 changed files with 5847 additions and 62 deletions

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');
}
};

View File

@@ -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::table('bank_accounts', function (Blueprint $table) {
// 예금 종류
$table->string('account_type', 30)->default('보통예금')->after('account_holder')->comment('예금종류');
// 금액 정보
$table->decimal('balance', 18, 2)->default(0)->after('account_name')->comment('잔액');
$table->string('currency', 3)->default('KRW')->after('balance')->comment('통화');
// 날짜 정보
$table->date('opened_at')->nullable()->after('currency')->comment('개설일자');
$table->timestamp('last_transaction_at')->nullable()->after('opened_at')->comment('최종거래일시');
// 추가 정보
$table->string('branch_name', 100)->nullable()->after('last_transaction_at')->comment('지점명');
$table->text('memo')->nullable()->after('branch_name')->comment('메모');
// 정렬 순서
$table->unsignedInteger('sort_order')->default(0)->after('is_primary')->comment('정렬순서');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('bank_accounts', function (Blueprint $table) {
$table->dropColumn([
'account_type',
'balance',
'currency',
'opened_at',
'last_transaction_at',
'branch_name',
'memo',
'sort_order',
]);
});
}
};

View File

@@ -0,0 +1,72 @@
<?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('bank_transactions', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
$table->foreignId('bank_account_id')->constrained('bank_accounts')->cascadeOnDelete();
// 거래 정보
$table->string('transaction_type', 20)->comment('거래유형: deposit(입금), withdrawal(출금), transfer(이체)');
$table->decimal('amount', 18, 2)->comment('거래금액');
$table->decimal('balance_after', 18, 2)->comment('거래 후 잔액');
// 날짜
$table->date('transaction_date')->comment('거래일자');
$table->time('transaction_time')->nullable()->comment('거래시간');
// 상세 정보
$table->string('description', 255)->nullable()->comment('적요');
$table->string('counterparty', 100)->nullable()->comment('거래상대방');
$table->string('reference_number', 100)->nullable()->comment('참조번호');
// 분류
$table->string('category', 50)->nullable()->comment('거래분류');
$table->foreignId('related_order_id')->nullable()->comment('관련 주문 ID');
$table->foreignId('related_payment_id')->nullable()->comment('관련 결제 ID');
// 상태
$table->boolean('is_reconciled')->default(false)->comment('대사완료 여부');
$table->timestamp('reconciled_at')->nullable()->comment('대사완료 일시');
// 추가 정보
$table->text('memo')->nullable()->comment('메모');
$table->json('options')->nullable()->comment('추가 옵션');
// 감사 필드
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
$table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
$table->foreignId('deleted_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
$table->softDeletes();
// 인덱스
$table->index('tenant_id', 'idx_bank_transactions_tenant');
$table->index('bank_account_id', 'idx_bank_transactions_account');
$table->index('transaction_date', 'idx_bank_transactions_date');
$table->index('transaction_type', 'idx_bank_transactions_type');
$table->index('is_reconciled', 'idx_bank_transactions_reconciled');
$table->index('deleted_at', 'idx_bank_transactions_deleted');
$table->index(['tenant_id', 'transaction_date'], 'idx_bank_transactions_tenant_date');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('bank_transactions');
}
};

View File

@@ -0,0 +1,75 @@
<?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('fund_schedules', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
// 기본 정보
$table->string('title', 200)->comment('일정명');
$table->text('description')->nullable()->comment('설명');
// 일정 유형: income(입금예정), expense(지급예정)
$table->enum('schedule_type', ['income', 'expense'])->comment('일정유형: income=입금, expense=지급');
// 일정 정보
$table->date('scheduled_date')->comment('예정일');
$table->decimal('amount', 18, 2)->default(0)->comment('금액');
$table->string('currency', 3)->default('KRW')->comment('통화');
// 관련 정보
$table->unsignedBigInteger('related_bank_account_id')->nullable()->comment('관련 계좌 ID');
$table->string('counterparty', 200)->nullable()->comment('거래상대방');
$table->string('category', 50)->nullable()->comment('분류');
// 상태: pending(예정), completed(완료), cancelled(취소)
$table->enum('status', ['pending', 'completed', 'cancelled'])->default('pending')->comment('상태');
// 반복 설정
$table->boolean('is_recurring')->default(false)->comment('정기 여부');
$table->string('recurrence_rule', 100)->nullable()->comment('반복 규칙 (daily, weekly, monthly, yearly)');
$table->date('recurrence_end_date')->nullable()->comment('반복 종료일');
// 완료 정보
$table->date('completed_date')->nullable()->comment('실제 완료일');
$table->decimal('completed_amount', 18, 2)->nullable()->comment('실제 완료 금액');
// 추가 정보
$table->text('memo')->nullable()->comment('메모');
// 감사 필드
$table->unsignedBigInteger('created_by')->nullable()->comment('생성자 ID');
$table->unsignedBigInteger('updated_by')->nullable()->comment('수정자 ID');
$table->unsignedBigInteger('deleted_by')->nullable()->comment('삭제자 ID');
$table->timestamps();
$table->softDeletes();
// 인덱스
$table->index('tenant_id', 'idx_fund_schedules_tenant');
$table->index('scheduled_date', 'idx_fund_schedules_date');
$table->index('schedule_type', 'idx_fund_schedules_type');
$table->index('status', 'idx_fund_schedules_status');
$table->index(['tenant_id', 'scheduled_date'], 'idx_fund_schedules_tenant_date');
$table->index('deleted_at', 'idx_fund_schedules_deleted');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('fund_schedules');
}
};