feat:MNG 마이그레이션 파일 전체 이동
MNG에서 API로 이동된 마이그레이션: - sales_scenario_checklists - simulator_fields, category_groups - barobill_members, barobill_configs - coocon_configs, credit_inquiries - barobill_bank_transactions, account_codes - barobill_card_transactions 관련 테이블들 모든 DB 마이그레이션은 API 프로젝트에서 관리 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
<?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_scenario_checklists', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->unsignedTinyInteger('step_id')->comment('단계 ID (1-6)');
|
||||||
|
$table->unsignedTinyInteger('checkpoint_index')->comment('체크포인트 인덱스');
|
||||||
|
$table->boolean('is_checked')->default(true);
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
// 복합 유니크 키: 사용자별, 단계별, 체크포인트별 하나의 레코드
|
||||||
|
$table->unique(['tenant_id', 'user_id', 'step_id', 'checkpoint_index'], 'sales_scenario_unique');
|
||||||
|
$table->index(['tenant_id', 'user_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('sales_scenario_checklists');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* Design 시뮬레이터 동기화를 위한 items 테이블 필드 추가
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('items', function (Blueprint $table) {
|
||||||
|
// 공정유형: screen(스크린), bending(절곡), electric(전기), steel(철재), assembly(조립)
|
||||||
|
$table->string('process_type', 20)->nullable()->after('category_id')
|
||||||
|
->comment('공정유형: screen, bending, electric, steel, assembly');
|
||||||
|
|
||||||
|
// 품목분류: 원단, 패널, 도장, 표면처리, 가이드레일, 케이스, 모터, 제어반 등
|
||||||
|
$table->string('item_category', 50)->nullable()->after('process_type')
|
||||||
|
->comment('품목분류: 원단, 패널, 도장, 가이드레일, 모터 등');
|
||||||
|
|
||||||
|
// 인덱스 추가
|
||||||
|
$table->index('process_type', 'idx_items_process_type');
|
||||||
|
$table->index('item_category', 'idx_items_item_category');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('items', function (Blueprint $table) {
|
||||||
|
$table->dropIndex('idx_items_process_type');
|
||||||
|
$table->dropIndex('idx_items_item_category');
|
||||||
|
$table->dropColumn(['process_type', 'item_category']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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('category_groups', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
||||||
|
|
||||||
|
// 코드: area_based, weight_based, quantity_based
|
||||||
|
$table->string('code', 50)->comment('코드: area_based, weight_based, quantity_based');
|
||||||
|
|
||||||
|
// 이름: 면적기반, 중량기반, 수량기반
|
||||||
|
$table->string('name', 100)->comment('이름: 면적기반, 중량기반, 수량기반');
|
||||||
|
|
||||||
|
// 곱셈 변수: M(면적), K(중량), null(수량)
|
||||||
|
$table->string('multiplier_variable', 20)->nullable()
|
||||||
|
->comment('곱셈 변수: M(면적), K(중량), null(수량기반)');
|
||||||
|
|
||||||
|
// 소속 카테고리 목록 (JSON 배열)
|
||||||
|
$table->json('categories')->nullable()
|
||||||
|
->comment('소속 카테고리 목록: ["원단", "패널", "도장"]');
|
||||||
|
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->unsignedInteger('sort_order')->default(0);
|
||||||
|
$table->boolean('is_active')->default(true);
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
// 인덱스
|
||||||
|
$table->index('tenant_id', 'idx_category_groups_tenant');
|
||||||
|
$table->unique(['tenant_id', 'code'], 'uq_category_groups_tenant_code');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('category_groups');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?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('barobill_members', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->string('biz_no', 20)->comment('사업자번호');
|
||||||
|
$table->string('corp_name', 100)->comment('상호명');
|
||||||
|
$table->string('ceo_name', 50)->comment('대표자명');
|
||||||
|
$table->string('addr', 255)->nullable()->comment('주소');
|
||||||
|
$table->string('biz_type', 50)->nullable()->comment('업태');
|
||||||
|
$table->string('biz_class', 50)->nullable()->comment('종목');
|
||||||
|
$table->string('barobill_id', 50)->comment('바로빌 아이디');
|
||||||
|
$table->string('barobill_pwd', 255)->comment('바로빌 비밀번호 (해시)');
|
||||||
|
$table->string('manager_name', 50)->nullable()->comment('담당자명');
|
||||||
|
$table->string('manager_email', 100)->nullable()->comment('담당자 이메일');
|
||||||
|
$table->string('manager_hp', 20)->nullable()->comment('담당자 전화번호');
|
||||||
|
$table->enum('status', ['active', 'inactive', 'pending'])->default('active')->comment('상태');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->unique(['tenant_id', 'biz_no'], 'unique_tenant_biz_no');
|
||||||
|
$table->index('status');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('barobill_members');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* 바로빌 API 설정 테이블
|
||||||
|
* - 테스트/운영 서버별 인증키 및 URL 관리
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('barobill_configs', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name', 50)->comment('설정 이름 (예: 테스트서버, 운영서버)');
|
||||||
|
$table->enum('environment', ['test', 'production'])->comment('환경 (test/production)');
|
||||||
|
$table->string('cert_key', 100)->comment('CERTKEY (인증키)');
|
||||||
|
$table->string('corp_num', 20)->nullable()->comment('파트너 사업자번호');
|
||||||
|
$table->string('base_url', 255)->comment('API 서버 URL');
|
||||||
|
$table->text('description')->nullable()->comment('설명');
|
||||||
|
$table->boolean('is_active')->default(false)->comment('활성화 여부 (환경당 1개만 활성화)');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
// 환경별로 하나만 활성화 가능하도록 부분 유니크 인덱스 (is_active=true인 것 중에서)
|
||||||
|
$table->index(['environment', 'is_active']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('barobill_configs');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?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('barobill_settings', function (Blueprint $table) {
|
||||||
|
// 서비스 이용 옵션
|
||||||
|
$table->boolean('use_tax_invoice')->default(false)->after('auto_issue')->comment('전자세금계산서 이용');
|
||||||
|
$table->boolean('use_bank_account')->default(false)->after('use_tax_invoice')->comment('계좌조회 이용');
|
||||||
|
$table->boolean('use_card_usage')->default(false)->after('use_bank_account')->comment('카드사용내역 이용');
|
||||||
|
$table->boolean('use_hometax')->default(false)->after('use_card_usage')->comment('홈텍스매입/매출 이용');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('barobill_settings', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['use_tax_invoice', 'use_bank_account', 'use_card_usage', 'use_hometax']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?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('coocon_configs', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name', 100)->comment('설정 이름');
|
||||||
|
$table->enum('environment', ['test', 'production'])->default('test')->comment('환경');
|
||||||
|
$table->string('api_key', 100)->comment('API 키');
|
||||||
|
$table->string('base_url', 255)->comment('API 기본 URL');
|
||||||
|
$table->text('description')->nullable()->comment('설명');
|
||||||
|
$table->boolean('is_active')->default(false)->comment('활성화 여부');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('coocon_configs');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?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('credit_inquiries', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('inquiry_key', 32)->unique()->comment('조회 고유 키');
|
||||||
|
$table->string('company_key', 20)->index()->comment('사업자번호/법인번호');
|
||||||
|
$table->string('company_name')->nullable()->comment('업체명');
|
||||||
|
$table->unsignedBigInteger('user_id')->nullable()->comment('조회자 ID');
|
||||||
|
$table->timestamp('inquired_at')->comment('조회 일시');
|
||||||
|
|
||||||
|
// 요약 정보 (빠른 조회용)
|
||||||
|
$table->unsignedInteger('short_term_overdue_cnt')->default(0)->comment('단기연체정보 건수');
|
||||||
|
$table->unsignedInteger('negative_info_kci_cnt')->default(0)->comment('신용도판단정보(한국신용정보원) 건수');
|
||||||
|
$table->unsignedInteger('negative_info_pb_cnt')->default(0)->comment('공공정보 건수');
|
||||||
|
$table->unsignedInteger('negative_info_cb_cnt')->default(0)->comment('신용도판단정보(신용정보사) 건수');
|
||||||
|
$table->unsignedInteger('suspension_info_cnt')->default(0)->comment('당좌거래정지정보 건수');
|
||||||
|
$table->unsignedInteger('workout_cnt')->default(0)->comment('법정관리/워크아웃정보 건수');
|
||||||
|
|
||||||
|
// API 응답 원본 데이터 (JSON)
|
||||||
|
$table->json('raw_summary')->nullable()->comment('OA12 신용요약정보 원본');
|
||||||
|
$table->json('raw_short_term_overdue')->nullable()->comment('OA13 단기연체정보 원본');
|
||||||
|
$table->json('raw_negative_info_kci')->nullable()->comment('OA14 신용도판단정보(한국신용정보원) 원본');
|
||||||
|
$table->json('raw_negative_info_cb')->nullable()->comment('OA15 신용도판단정보(신용정보사) 원본');
|
||||||
|
$table->json('raw_suspension_info')->nullable()->comment('OA16 당좌거래정지정보 원본');
|
||||||
|
$table->json('raw_workout_info')->nullable()->comment('OA17 법정관리/워크아웃정보 원본');
|
||||||
|
|
||||||
|
// 상태
|
||||||
|
$table->enum('status', ['success', 'partial', 'failed'])->default('success')->comment('조회 상태');
|
||||||
|
$table->text('error_message')->nullable()->comment('에러 메시지');
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
// 인덱스
|
||||||
|
$table->index(['company_key', 'inquired_at']);
|
||||||
|
$table->index('inquired_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('credit_inquiries');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?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('credit_inquiries', function (Blueprint $table) {
|
||||||
|
// 기업 기본정보 (OA08)
|
||||||
|
$table->string('ceo_name')->nullable()->after('company_name')->comment('대표자명');
|
||||||
|
$table->string('company_address')->nullable()->after('ceo_name')->comment('회사 주소');
|
||||||
|
$table->string('business_type')->nullable()->after('company_address')->comment('업종');
|
||||||
|
$table->string('business_item')->nullable()->after('business_type')->comment('업태');
|
||||||
|
$table->date('establishment_date')->nullable()->after('business_item')->comment('설립일');
|
||||||
|
|
||||||
|
// 국세청 사업자등록 상태
|
||||||
|
$table->string('nts_status', 20)->nullable()->after('establishment_date')->comment('국세청 상태 (영업/휴업/폐업)');
|
||||||
|
$table->string('nts_status_code', 2)->nullable()->after('nts_status')->comment('국세청 상태코드 (01/02/03)');
|
||||||
|
$table->string('nts_tax_type', 50)->nullable()->after('nts_status_code')->comment('과세유형');
|
||||||
|
$table->date('nts_closure_date')->nullable()->after('nts_tax_type')->comment('폐업일');
|
||||||
|
|
||||||
|
// API 원본 데이터
|
||||||
|
$table->json('raw_company_info')->nullable()->after('raw_workout_info')->comment('OA08 기업기본정보 원본');
|
||||||
|
$table->json('raw_nts_status')->nullable()->after('raw_company_info')->comment('국세청 상태조회 원본');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('credit_inquiries', function (Blueprint $table) {
|
||||||
|
$table->dropColumn([
|
||||||
|
'ceo_name',
|
||||||
|
'company_address',
|
||||||
|
'business_type',
|
||||||
|
'business_item',
|
||||||
|
'establishment_date',
|
||||||
|
'nts_status',
|
||||||
|
'nts_status_code',
|
||||||
|
'nts_tax_type',
|
||||||
|
'nts_closure_date',
|
||||||
|
'raw_company_info',
|
||||||
|
'raw_nts_status',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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('barobill_bank_transactions', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('tenant_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('bank_account_num', 50)->comment('계좌번호');
|
||||||
|
$table->string('bank_code', 10)->nullable()->comment('은행코드');
|
||||||
|
$table->string('bank_name', 50)->nullable()->comment('은행명');
|
||||||
|
$table->string('trans_date', 8)->comment('거래일 (YYYYMMDD)');
|
||||||
|
$table->string('trans_time', 6)->nullable()->comment('거래시간 (HHMMSS)');
|
||||||
|
$table->string('trans_dt', 20)->comment('거래일시 원본 (YYYYMMDDHHMMSS)');
|
||||||
|
$table->decimal('deposit', 18, 2)->default(0)->comment('입금액');
|
||||||
|
$table->decimal('withdraw', 18, 2)->default(0)->comment('출금액');
|
||||||
|
$table->decimal('balance', 18, 2)->default(0)->comment('잔액');
|
||||||
|
$table->string('summary', 255)->nullable()->comment('적요');
|
||||||
|
$table->string('cast', 100)->nullable()->comment('상대방');
|
||||||
|
$table->string('memo', 255)->nullable()->comment('메모');
|
||||||
|
$table->string('trans_office', 100)->nullable()->comment('거래점');
|
||||||
|
$table->string('account_code', 50)->nullable()->comment('계정과목 코드');
|
||||||
|
$table->string('account_name', 100)->nullable()->comment('계정과목 명');
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
// 복합 유니크 인덱스: 같은 거래는 중복 저장 방지
|
||||||
|
$table->unique(
|
||||||
|
['tenant_id', 'bank_account_num', 'trans_dt', 'deposit', 'withdraw', 'balance'],
|
||||||
|
'barobill_bank_trans_unique'
|
||||||
|
);
|
||||||
|
|
||||||
|
// 조회용 인덱스
|
||||||
|
$table->index(['tenant_id', 'trans_date'], 'bb_trans_tenant_date_idx');
|
||||||
|
$table->index(['tenant_id', 'bank_account_num', 'trans_date'], 'bb_trans_tenant_acct_date_idx');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('barobill_bank_transactions');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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('account_codes', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('tenant_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('code', 10)->comment('계정과목 코드');
|
||||||
|
$table->string('name', 100)->comment('계정과목 명');
|
||||||
|
$table->string('category', 50)->nullable()->comment('분류 (자산/부채/자본/수익/비용)');
|
||||||
|
$table->integer('sort_order')->default(0)->comment('정렬순서');
|
||||||
|
$table->boolean('is_active')->default(true)->comment('사용여부');
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
// 테넌트별 계정과목 코드 유니크
|
||||||
|
$table->unique(['tenant_id', 'code'], 'account_codes_tenant_code_unique');
|
||||||
|
$table->index(['tenant_id', 'is_active'], 'account_codes_tenant_active_idx');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('account_codes');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?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('barobill_card_transactions', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('tenant_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('card_num', 50)->comment('카드번호');
|
||||||
|
$table->string('card_company', 10)->nullable()->comment('카드사 코드');
|
||||||
|
$table->string('card_company_name', 50)->nullable()->comment('카드사명');
|
||||||
|
$table->string('use_dt', 20)->comment('사용일시 원본 (YYYYMMDDHHMMSS)');
|
||||||
|
$table->string('use_date', 8)->comment('사용일 (YYYYMMDD)');
|
||||||
|
$table->string('use_time', 6)->nullable()->comment('사용시간 (HHMMSS)');
|
||||||
|
$table->string('approval_num', 50)->nullable()->comment('승인번호');
|
||||||
|
$table->string('approval_type', 10)->nullable()->comment('승인유형 (1=승인, 2=취소)');
|
||||||
|
$table->decimal('approval_amount', 18, 2)->default(0)->comment('승인금액');
|
||||||
|
$table->decimal('tax', 18, 2)->default(0)->comment('부가세');
|
||||||
|
$table->decimal('service_charge', 18, 2)->default(0)->comment('봉사료');
|
||||||
|
$table->string('payment_plan', 10)->nullable()->comment('할부개월수');
|
||||||
|
$table->string('currency_code', 10)->default('KRW')->comment('통화코드');
|
||||||
|
$table->string('merchant_name', 255)->nullable()->comment('가맹점명');
|
||||||
|
$table->string('merchant_biz_num', 20)->nullable()->comment('가맹점 사업자번호');
|
||||||
|
$table->string('merchant_addr', 255)->nullable()->comment('가맹점 주소');
|
||||||
|
$table->string('merchant_ceo', 100)->nullable()->comment('가맹점 대표자');
|
||||||
|
$table->string('merchant_biz_type', 100)->nullable()->comment('가맹점 업종');
|
||||||
|
$table->string('merchant_tel', 50)->nullable()->comment('가맹점 전화번호');
|
||||||
|
$table->string('memo', 255)->nullable()->comment('메모');
|
||||||
|
$table->string('use_key', 100)->nullable()->comment('사용키');
|
||||||
|
$table->string('account_code', 50)->nullable()->comment('계정과목 코드');
|
||||||
|
$table->string('account_name', 100)->nullable()->comment('계정과목 명');
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
// 복합 유니크 인덱스: 같은 거래는 중복 저장 방지
|
||||||
|
$table->unique(
|
||||||
|
['tenant_id', 'card_num', 'use_dt', 'approval_num', 'approval_amount'],
|
||||||
|
'bb_card_trans_unique'
|
||||||
|
);
|
||||||
|
|
||||||
|
// 조회용 인덱스
|
||||||
|
$table->index(['tenant_id', 'use_date'], 'bb_card_trans_tenant_date_idx');
|
||||||
|
$table->index(['tenant_id', 'card_num', 'use_date'], 'bb_card_trans_tenant_card_date_idx');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('barobill_card_transactions');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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::create('barobill_card_transaction_splits', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('tenant_id')->constrained()->onDelete('cascade');
|
||||||
|
|
||||||
|
// 원본 거래 고유키 (바로빌에서 가져온 원본 데이터 식별)
|
||||||
|
$table->string('original_unique_key', 200)->comment('원본 거래 고유키 (cardNum|useDt|approvalNum|amount)');
|
||||||
|
|
||||||
|
// 분개 정보
|
||||||
|
$table->decimal('split_amount', 18, 2)->comment('분개 금액');
|
||||||
|
$table->string('account_code', 50)->nullable()->comment('계정과목 코드');
|
||||||
|
$table->string('account_name', 100)->nullable()->comment('계정과목명');
|
||||||
|
$table->string('memo', 255)->nullable()->comment('분개 메모');
|
||||||
|
$table->integer('sort_order')->default(0)->comment('정렬 순서');
|
||||||
|
|
||||||
|
// 원본 거래 정보 (조회 편의를 위해 저장)
|
||||||
|
$table->string('card_num', 50)->comment('카드번호');
|
||||||
|
$table->string('use_dt', 20)->comment('사용일시 (YYYYMMDDHHMMSS)');
|
||||||
|
$table->string('use_date', 8)->comment('사용일 (YYYYMMDD)');
|
||||||
|
$table->string('approval_num', 50)->nullable()->comment('승인번호');
|
||||||
|
$table->decimal('original_amount', 18, 2)->comment('원본 거래 총액');
|
||||||
|
$table->string('merchant_name', 255)->nullable()->comment('가맹점명');
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
// 인덱스
|
||||||
|
$table->index(['tenant_id', 'original_unique_key'], 'bb_card_split_tenant_key_idx');
|
||||||
|
$table->index(['tenant_id', 'use_date'], 'bb_card_split_tenant_date_idx');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('barobill_card_transaction_splits');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?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('barobill_card_transactions', function (Blueprint $table) {
|
||||||
|
// 공제 유형: 공제(deductible) / 불공(non_deductible)
|
||||||
|
$table->string('deduction_type', 20)->nullable()->after('account_name')->comment('공제유형: deductible/non_deductible');
|
||||||
|
// 증빙/판매자상호 (사용자 수정용)
|
||||||
|
$table->string('evidence_name', 255)->nullable()->after('deduction_type')->comment('증빙/판매자상호 (수정용)');
|
||||||
|
// 내역 (사용자 수정용)
|
||||||
|
$table->string('description', 500)->nullable()->after('evidence_name')->comment('내역 (수정용)');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('barobill_card_transactions', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['deduction_type', 'evidence_name', 'description']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?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('barobill_card_transaction_splits', function (Blueprint $table) {
|
||||||
|
$table->string('evidence_name', 255)->nullable()->after('account_name')->comment('증빙/판매자상호');
|
||||||
|
$table->string('description', 500)->nullable()->after('evidence_name')->comment('내역');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('barobill_card_transaction_splits', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['evidence_name', 'description']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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('barobill_card_transaction_splits', function (Blueprint $table) {
|
||||||
|
$table->string('deduction_type', 20)->nullable()->after('account_name')->comment('공제유형: deductible/non_deductible');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('barobill_card_transaction_splits', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('deduction_type');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user