From 39a8d8e2df9836cb742bea57d595eb6ac7d0f80b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Thu, 19 Mar 2026 20:21:42 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20[db]=20=EB=AA=A8=EB=8D=B8=20connect?= =?UTF-8?q?ion=EC=9D=84=20codebridge=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20+=20?= =?UTF-8?q?=EB=A7=88=EC=9D=B4=EA=B7=B8=EB=A0=88=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=A0=84=EC=B2=B4=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PMIS 모델 21개 + DailyWorkLog 2개에 $connection = 'codebridge' 추가 - MNG 마이그레이션 파일 18개 전체 삭제 (API에서 관리) - 원칙: MNG는 마이그레이션 파일을 생성하지 않고 API에서만 관리 --- app/Models/Finance/DailyWorkLog.php | 2 + app/Models/Finance/DailyWorkLogItem.php | 2 + app/Models/Juil/PmisArchiveFile.php | 2 + app/Models/Juil/PmisArchiveFolder.php | 2 + app/Models/Juil/PmisAttendanceEquipment.php | 2 + app/Models/Juil/PmisAttendanceWorker.php | 2 + app/Models/Juil/PmisConstructionWorker.php | 2 + app/Models/Juil/PmisDailyAttendance.php | 2 + app/Models/Juil/PmisDailyWorkReport.php | 2 + app/Models/Juil/PmisEquipment.php | 2 + app/Models/Juil/PmisJobType.php | 2 + app/Models/Juil/PmisManual.php | 2 + app/Models/Juil/PmisManualAttachment.php | 2 + app/Models/Juil/PmisMaterial.php | 2 + app/Models/Juil/PmisNotice.php | 2 + app/Models/Juil/PmisNoticeAttachment.php | 2 + app/Models/Juil/PmisWorkReportEquipment.php | 2 + app/Models/Juil/PmisWorkReportMaterial.php | 2 + app/Models/Juil/PmisWorkReportPhoto.php | 2 + app/Models/Juil/PmisWorkReportVolume.php | 2 + app/Models/Juil/PmisWorkReportWorker.php | 2 + app/Models/Juil/PmisWorkVolume.php | 2 + app/Models/Juil/PmisWorker.php | 2 + ...03_12_120000_create_pmis_workers_table.php | 38 ------- ..._12_140000_create_pmis_job_types_table.php | 30 ----- ...create_pmis_construction_workers_table.php | 39 ------- ...12_150000_create_pmis_equipments_table.php | 39 ------- ..._12_160000_create_pmis_materials_table.php | 34 ------ ..._170000_create_pmis_work_volumes_table.php | 29 ----- ...00_create_pmis_daily_attendances_table.php | 31 ----- ...1_create_pmis_attendance_workers_table.php | 34 ------ ...reate_pmis_attendance_equipments_table.php | 34 ------ ...0_create_pmis_daily_work_reports_table.php | 39 ------- ...create_pmis_work_report_details_tables.php | 104 ----------------- ...3_12_203417_create_pmis_archive_tables.php | 51 --------- ...03_12_204558_create_pmis_manuals_table.php | 41 ------- ...03_12_205226_create_pmis_notices_table.php | 40 ------- ...0000_fix_duplicate_journal_entry_lines.php | 92 --------------- ...3_180000_create_daily_work_logs_tables.php | 48 -------- ...bridge_account_codes_with_kis_standard.php | 51 --------- ...migrate_3digit_to_5digit_account_codes.php | 107 ------------------ 41 files changed, 46 insertions(+), 881 deletions(-) delete mode 100644 database/migrations/2026_03_12_120000_create_pmis_workers_table.php delete mode 100644 database/migrations/2026_03_12_140000_create_pmis_job_types_table.php delete mode 100644 database/migrations/2026_03_12_140001_create_pmis_construction_workers_table.php delete mode 100644 database/migrations/2026_03_12_150000_create_pmis_equipments_table.php delete mode 100644 database/migrations/2026_03_12_160000_create_pmis_materials_table.php delete mode 100644 database/migrations/2026_03_12_170000_create_pmis_work_volumes_table.php delete mode 100644 database/migrations/2026_03_12_180000_create_pmis_daily_attendances_table.php delete mode 100644 database/migrations/2026_03_12_180001_create_pmis_attendance_workers_table.php delete mode 100644 database/migrations/2026_03_12_180002_create_pmis_attendance_equipments_table.php delete mode 100644 database/migrations/2026_03_12_190000_create_pmis_daily_work_reports_table.php delete mode 100644 database/migrations/2026_03_12_190001_create_pmis_work_report_details_tables.php delete mode 100644 database/migrations/2026_03_12_203417_create_pmis_archive_tables.php delete mode 100644 database/migrations/2026_03_12_204558_create_pmis_manuals_table.php delete mode 100644 database/migrations/2026_03_12_205226_create_pmis_notices_table.php delete mode 100644 database/migrations/2026_03_13_100000_fix_duplicate_journal_entry_lines.php delete mode 100644 database/migrations/2026_03_13_180000_create_daily_work_logs_tables.php delete mode 100644 database/migrations/2026_03_17_112601_replace_codebridge_account_codes_with_kis_standard.php delete mode 100644 database/migrations/2026_03_19_160707_migrate_3digit_to_5digit_account_codes.php diff --git a/app/Models/Finance/DailyWorkLog.php b/app/Models/Finance/DailyWorkLog.php index 62d3aba2..5a98ba0a 100644 --- a/app/Models/Finance/DailyWorkLog.php +++ b/app/Models/Finance/DailyWorkLog.php @@ -12,6 +12,8 @@ class DailyWorkLog extends Model { use BelongsToTenant, ModelTrait, SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'daily_work_logs'; protected $fillable = [ diff --git a/app/Models/Finance/DailyWorkLogItem.php b/app/Models/Finance/DailyWorkLogItem.php index 662c1546..c85295b4 100644 --- a/app/Models/Finance/DailyWorkLogItem.php +++ b/app/Models/Finance/DailyWorkLogItem.php @@ -12,6 +12,8 @@ class DailyWorkLogItem extends Model { use BelongsToTenant, ModelTrait, SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'daily_work_log_items'; protected $fillable = [ diff --git a/app/Models/Juil/PmisArchiveFile.php b/app/Models/Juil/PmisArchiveFile.php index f905a198..2169c7e6 100644 --- a/app/Models/Juil/PmisArchiveFile.php +++ b/app/Models/Juil/PmisArchiveFile.php @@ -11,6 +11,8 @@ class PmisArchiveFile extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $fillable = [ 'tenant_id', 'folder_id', diff --git a/app/Models/Juil/PmisArchiveFolder.php b/app/Models/Juil/PmisArchiveFolder.php index e12c7aa4..d1b847a3 100644 --- a/app/Models/Juil/PmisArchiveFolder.php +++ b/app/Models/Juil/PmisArchiveFolder.php @@ -10,6 +10,8 @@ class PmisArchiveFolder extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $fillable = [ 'tenant_id', 'parent_id', diff --git a/app/Models/Juil/PmisAttendanceEquipment.php b/app/Models/Juil/PmisAttendanceEquipment.php index 1cd03939..513ba9e3 100644 --- a/app/Models/Juil/PmisAttendanceEquipment.php +++ b/app/Models/Juil/PmisAttendanceEquipment.php @@ -10,6 +10,8 @@ class PmisAttendanceEquipment extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'pmis_attendance_equipments'; protected $fillable = [ diff --git a/app/Models/Juil/PmisAttendanceWorker.php b/app/Models/Juil/PmisAttendanceWorker.php index 0f5234eb..55265360 100644 --- a/app/Models/Juil/PmisAttendanceWorker.php +++ b/app/Models/Juil/PmisAttendanceWorker.php @@ -10,6 +10,8 @@ class PmisAttendanceWorker extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'pmis_attendance_workers'; protected $fillable = [ diff --git a/app/Models/Juil/PmisConstructionWorker.php b/app/Models/Juil/PmisConstructionWorker.php index e9068f75..7dc3f58a 100644 --- a/app/Models/Juil/PmisConstructionWorker.php +++ b/app/Models/Juil/PmisConstructionWorker.php @@ -10,6 +10,8 @@ class PmisConstructionWorker extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'pmis_construction_workers'; protected $fillable = [ diff --git a/app/Models/Juil/PmisDailyAttendance.php b/app/Models/Juil/PmisDailyAttendance.php index 88b023d8..4c237685 100644 --- a/app/Models/Juil/PmisDailyAttendance.php +++ b/app/Models/Juil/PmisDailyAttendance.php @@ -10,6 +10,8 @@ class PmisDailyAttendance extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'pmis_daily_attendances'; protected $fillable = [ diff --git a/app/Models/Juil/PmisDailyWorkReport.php b/app/Models/Juil/PmisDailyWorkReport.php index 1ae32be0..a283b971 100644 --- a/app/Models/Juil/PmisDailyWorkReport.php +++ b/app/Models/Juil/PmisDailyWorkReport.php @@ -10,6 +10,8 @@ class PmisDailyWorkReport extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'pmis_daily_work_reports'; protected $fillable = [ diff --git a/app/Models/Juil/PmisEquipment.php b/app/Models/Juil/PmisEquipment.php index 1a96cf11..b0acc6b2 100644 --- a/app/Models/Juil/PmisEquipment.php +++ b/app/Models/Juil/PmisEquipment.php @@ -9,6 +9,8 @@ class PmisEquipment extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'pmis_equipments'; protected $fillable = [ diff --git a/app/Models/Juil/PmisJobType.php b/app/Models/Juil/PmisJobType.php index 3cd8d2fa..36787c47 100644 --- a/app/Models/Juil/PmisJobType.php +++ b/app/Models/Juil/PmisJobType.php @@ -9,6 +9,8 @@ class PmisJobType extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'pmis_job_types'; protected $fillable = [ diff --git a/app/Models/Juil/PmisManual.php b/app/Models/Juil/PmisManual.php index 2f642af3..8086230b 100644 --- a/app/Models/Juil/PmisManual.php +++ b/app/Models/Juil/PmisManual.php @@ -12,6 +12,8 @@ class PmisManual extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $fillable = [ 'tenant_id', 'title', diff --git a/app/Models/Juil/PmisManualAttachment.php b/app/Models/Juil/PmisManualAttachment.php index 9eba18dc..865af405 100644 --- a/app/Models/Juil/PmisManualAttachment.php +++ b/app/Models/Juil/PmisManualAttachment.php @@ -7,6 +7,8 @@ class PmisManualAttachment extends Model { + protected $connection = 'codebridge'; + protected $fillable = [ 'manual_id', 'original_name', diff --git a/app/Models/Juil/PmisMaterial.php b/app/Models/Juil/PmisMaterial.php index ad52a966..292670f4 100644 --- a/app/Models/Juil/PmisMaterial.php +++ b/app/Models/Juil/PmisMaterial.php @@ -9,6 +9,8 @@ class PmisMaterial extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'pmis_materials'; protected $fillable = [ diff --git a/app/Models/Juil/PmisNotice.php b/app/Models/Juil/PmisNotice.php index 1128c349..43f25c9b 100644 --- a/app/Models/Juil/PmisNotice.php +++ b/app/Models/Juil/PmisNotice.php @@ -12,6 +12,8 @@ class PmisNotice extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $fillable = [ 'tenant_id', 'title', diff --git a/app/Models/Juil/PmisNoticeAttachment.php b/app/Models/Juil/PmisNoticeAttachment.php index 27e0024c..26f0963f 100644 --- a/app/Models/Juil/PmisNoticeAttachment.php +++ b/app/Models/Juil/PmisNoticeAttachment.php @@ -7,6 +7,8 @@ class PmisNoticeAttachment extends Model { + protected $connection = 'codebridge'; + protected $fillable = [ 'notice_id', 'original_name', diff --git a/app/Models/Juil/PmisWorkReportEquipment.php b/app/Models/Juil/PmisWorkReportEquipment.php index cd8354e2..9c3bf247 100644 --- a/app/Models/Juil/PmisWorkReportEquipment.php +++ b/app/Models/Juil/PmisWorkReportEquipment.php @@ -10,6 +10,8 @@ class PmisWorkReportEquipment extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'pmis_work_report_equipments'; protected $fillable = [ diff --git a/app/Models/Juil/PmisWorkReportMaterial.php b/app/Models/Juil/PmisWorkReportMaterial.php index a3715a31..74674587 100644 --- a/app/Models/Juil/PmisWorkReportMaterial.php +++ b/app/Models/Juil/PmisWorkReportMaterial.php @@ -10,6 +10,8 @@ class PmisWorkReportMaterial extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'pmis_work_report_materials'; protected $fillable = [ diff --git a/app/Models/Juil/PmisWorkReportPhoto.php b/app/Models/Juil/PmisWorkReportPhoto.php index 59a027b8..a1657241 100644 --- a/app/Models/Juil/PmisWorkReportPhoto.php +++ b/app/Models/Juil/PmisWorkReportPhoto.php @@ -10,6 +10,8 @@ class PmisWorkReportPhoto extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'pmis_work_report_photos'; protected $fillable = [ diff --git a/app/Models/Juil/PmisWorkReportVolume.php b/app/Models/Juil/PmisWorkReportVolume.php index 233234d7..82f57740 100644 --- a/app/Models/Juil/PmisWorkReportVolume.php +++ b/app/Models/Juil/PmisWorkReportVolume.php @@ -10,6 +10,8 @@ class PmisWorkReportVolume extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'pmis_work_report_volumes'; protected $fillable = [ diff --git a/app/Models/Juil/PmisWorkReportWorker.php b/app/Models/Juil/PmisWorkReportWorker.php index 0040fa13..600422a2 100644 --- a/app/Models/Juil/PmisWorkReportWorker.php +++ b/app/Models/Juil/PmisWorkReportWorker.php @@ -10,6 +10,8 @@ class PmisWorkReportWorker extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'pmis_work_report_workers'; protected $fillable = [ diff --git a/app/Models/Juil/PmisWorkVolume.php b/app/Models/Juil/PmisWorkVolume.php index 4a5b99d5..5e480c11 100644 --- a/app/Models/Juil/PmisWorkVolume.php +++ b/app/Models/Juil/PmisWorkVolume.php @@ -9,6 +9,8 @@ class PmisWorkVolume extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $table = 'pmis_work_volumes'; protected $fillable = [ diff --git a/app/Models/Juil/PmisWorker.php b/app/Models/Juil/PmisWorker.php index dbac5c71..67239d2e 100644 --- a/app/Models/Juil/PmisWorker.php +++ b/app/Models/Juil/PmisWorker.php @@ -11,6 +11,8 @@ class PmisWorker extends Model { use SoftDeletes; + protected $connection = 'codebridge'; + protected $fillable = [ 'tenant_id', 'user_id', diff --git a/database/migrations/2026_03_12_120000_create_pmis_workers_table.php b/database/migrations/2026_03_12_120000_create_pmis_workers_table.php deleted file mode 100644 index ffda5f3f..00000000 --- a/database/migrations/2026_03_12_120000_create_pmis_workers_table.php +++ /dev/null @@ -1,38 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id')->default(1)->index(); - $table->unsignedBigInteger('user_id')->nullable()->index()->comment('SAM users 테이블 FK (연결된 계정)'); - $table->string('name', 50); - $table->string('login_id', 50)->nullable()->comment('PMIS 로그인 아이디'); - $table->string('phone', 20)->nullable(); - $table->string('email', 255)->nullable(); - $table->string('department', 100)->nullable()->comment('소속 부서/현장소장 등'); - $table->string('position', 50)->nullable()->comment('직책'); - $table->string('role_type', 50)->nullable()->comment('권한 유형: 협력업체사용자, 원청관리자 등'); - $table->string('gender', 5)->nullable(); - $table->string('company', 100)->nullable()->comment('소속 업체명'); - $table->string('profile_photo_path', 500)->nullable(); - $table->json('options')->nullable(); - $table->timestamp('last_login_at')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->unique(['tenant_id', 'user_id'], 'pmis_workers_tenant_user_unique'); - }); - } - - public function down(): void - { - Schema::dropIfExists('pmis_workers'); - } -}; diff --git a/database/migrations/2026_03_12_140000_create_pmis_job_types_table.php b/database/migrations/2026_03_12_140000_create_pmis_job_types_table.php deleted file mode 100644 index 7fcaecda..00000000 --- a/database/migrations/2026_03_12_140000_create_pmis_job_types_table.php +++ /dev/null @@ -1,30 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id'); - $table->string('name', 100); - $table->integer('sort_order')->default(0); - $table->boolean('is_active')->default(true); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->index('tenant_id'); - $table->index(['tenant_id', 'name']); - }); - } - - public function down(): void - { - Schema::dropIfExists('pmis_job_types'); - } -}; diff --git a/database/migrations/2026_03_12_140001_create_pmis_construction_workers_table.php b/database/migrations/2026_03_12_140001_create_pmis_construction_workers_table.php deleted file mode 100644 index d2c021e9..00000000 --- a/database/migrations/2026_03_12_140001_create_pmis_construction_workers_table.php +++ /dev/null @@ -1,39 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id'); - $table->string('company_name', 200); - $table->string('trade_name', 100); - $table->unsignedBigInteger('job_type_id')->nullable(); - $table->string('name', 50); - $table->string('phone', 20)->nullable(); - $table->string('birth_date', 6)->nullable()->comment('YYMMDD'); - $table->char('ssn_gender', 1)->nullable()->comment('주민번호 뒷자리 첫째'); - $table->unsignedInteger('wage')->default(0); - $table->string('blood_type', 5)->nullable(); - $table->text('remark')->nullable(); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->index('tenant_id'); - $table->index(['tenant_id', 'company_name']); - $table->index(['tenant_id', 'name']); - $table->foreign('job_type_id')->references('id')->on('pmis_job_types')->nullOnDelete(); - }); - } - - public function down(): void - { - Schema::dropIfExists('pmis_construction_workers'); - } -}; diff --git a/database/migrations/2026_03_12_150000_create_pmis_equipments_table.php b/database/migrations/2026_03_12_150000_create_pmis_equipments_table.php deleted file mode 100644 index 30427424..00000000 --- a/database/migrations/2026_03_12_150000_create_pmis_equipments_table.php +++ /dev/null @@ -1,39 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id'); - $table->string('company_name', 200); - $table->string('equipment_code', 50)->nullable(); - $table->string('equipment_name', 200); - $table->string('specification', 300)->nullable(); - $table->string('unit', 50)->nullable(); - $table->string('equipment_number', 100); - $table->string('operator', 50)->nullable()->comment('운전원'); - $table->date('inspection_end_date')->nullable()->comment('검사종료일'); - $table->boolean('inspection_not_applicable')->default(false)->comment('검사 해당없음'); - $table->date('insurance_end_date')->nullable()->comment('보험종료일'); - $table->boolean('insurance_not_applicable')->default(false)->comment('보험 해당없음'); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->index('tenant_id'); - $table->index(['tenant_id', 'company_name']); - $table->index(['tenant_id', 'equipment_name']); - }); - } - - public function down(): void - { - Schema::dropIfExists('pmis_equipments'); - } -}; diff --git a/database/migrations/2026_03_12_160000_create_pmis_materials_table.php b/database/migrations/2026_03_12_160000_create_pmis_materials_table.php deleted file mode 100644 index 826429be..00000000 --- a/database/migrations/2026_03_12_160000_create_pmis_materials_table.php +++ /dev/null @@ -1,34 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id'); - $table->string('company_name', 200); - $table->string('material_code', 50)->nullable(); - $table->string('material_name', 200); - $table->string('specification', 300)->nullable(); - $table->string('unit', 50)->nullable(); - $table->decimal('design_quantity', 14, 2)->default(0)->comment('설계량'); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->index('tenant_id'); - $table->index(['tenant_id', 'company_name']); - $table->index(['tenant_id', 'material_name']); - }); - } - - public function down(): void - { - Schema::dropIfExists('pmis_materials'); - } -}; diff --git a/database/migrations/2026_03_12_170000_create_pmis_work_volumes_table.php b/database/migrations/2026_03_12_170000_create_pmis_work_volumes_table.php deleted file mode 100644 index 8ea179cb..00000000 --- a/database/migrations/2026_03_12_170000_create_pmis_work_volumes_table.php +++ /dev/null @@ -1,29 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id')->index(); - $table->string('work_type', 200)->comment('공종'); - $table->string('sub_work_type', 200)->comment('세부공종'); - $table->string('unit', 50)->comment('단위'); - $table->decimal('design_quantity', 14, 2)->default(0)->comment('설계량'); - $table->boolean('daily_report_applied')->default(false)->comment('일보적용'); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - }); - } - - public function down(): void - { - Schema::dropIfExists('pmis_work_volumes'); - } -}; diff --git a/database/migrations/2026_03_12_180000_create_pmis_daily_attendances_table.php b/database/migrations/2026_03_12_180000_create_pmis_daily_attendances_table.php deleted file mode 100644 index 46c703db..00000000 --- a/database/migrations/2026_03_12_180000_create_pmis_daily_attendances_table.php +++ /dev/null @@ -1,31 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id')->index(); - $table->date('date')->comment('일자'); - $table->string('company_name', 200)->default('')->comment('업체명'); - $table->string('weather', 50)->default('맑음')->comment('날씨'); - $table->enum('status', ['draft', 'review', 'approved'])->default('draft')->comment('상태'); - $table->text('notes')->nullable()->comment('특이사항'); - $table->json('options')->nullable()->comment('검토자 등 부가정보'); - $table->timestamps(); - $table->softDeletes(); - - $table->unique(['tenant_id', 'date', 'company_name'], 'pmis_attendance_unique'); - }); - } - - public function down(): void - { - Schema::dropIfExists('pmis_daily_attendances'); - } -}; diff --git a/database/migrations/2026_03_12_180001_create_pmis_attendance_workers_table.php b/database/migrations/2026_03_12_180001_create_pmis_attendance_workers_table.php deleted file mode 100644 index b598e0e4..00000000 --- a/database/migrations/2026_03_12_180001_create_pmis_attendance_workers_table.php +++ /dev/null @@ -1,34 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id')->index(); - $table->unsignedBigInteger('attendance_id')->index(); - $table->string('work_type', 200)->comment('공종'); - $table->string('job_type', 200)->comment('직종'); - $table->string('name', 100)->comment('성명'); - $table->decimal('man_days', 5, 1)->default(1.0)->comment('공수'); - $table->decimal('amount', 14, 0)->default(0)->comment('금액'); - $table->string('work_content', 500)->default('')->comment('작업내용'); - $table->integer('sort_order')->default(0); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->foreign('attendance_id')->references('id')->on('pmis_daily_attendances')->onDelete('cascade'); - }); - } - - public function down(): void - { - Schema::dropIfExists('pmis_attendance_workers'); - } -}; diff --git a/database/migrations/2026_03_12_180002_create_pmis_attendance_equipments_table.php b/database/migrations/2026_03_12_180002_create_pmis_attendance_equipments_table.php deleted file mode 100644 index 03dbf852..00000000 --- a/database/migrations/2026_03_12_180002_create_pmis_attendance_equipments_table.php +++ /dev/null @@ -1,34 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id')->index(); - $table->unsignedBigInteger('attendance_id')->index(); - $table->string('equipment_name', 200)->comment('장비명'); - $table->string('specification', 300)->default('')->comment('규격'); - $table->string('equipment_number', 100)->default('')->comment('장비번호'); - $table->string('operator', 100)->default('')->comment('운전원'); - $table->decimal('man_days', 5, 1)->default(1.0)->comment('공수'); - $table->string('work_content', 500)->default('')->comment('작업내용'); - $table->integer('sort_order')->default(0); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->foreign('attendance_id')->references('id')->on('pmis_daily_attendances')->onDelete('cascade'); - }); - } - - public function down(): void - { - Schema::dropIfExists('pmis_attendance_equipments'); - } -}; diff --git a/database/migrations/2026_03_12_190000_create_pmis_daily_work_reports_table.php b/database/migrations/2026_03_12_190000_create_pmis_daily_work_reports_table.php deleted file mode 100644 index 078b034f..00000000 --- a/database/migrations/2026_03_12_190000_create_pmis_daily_work_reports_table.php +++ /dev/null @@ -1,39 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id'); - $table->date('date'); - $table->string('company_name', 200)->default(''); - $table->string('weather', 50)->default('맑음'); - $table->decimal('temp_low', 5, 1)->nullable(); - $table->decimal('temp_high', 5, 1)->nullable(); - $table->decimal('precipitation', 8, 1)->default(0); - $table->decimal('snowfall', 8, 1)->default(0); - $table->string('fine_dust', 50)->default(''); - $table->string('ultra_fine_dust', 50)->default(''); - $table->text('work_content_today')->nullable(); - $table->text('work_content_tomorrow')->nullable(); - $table->text('notes')->nullable(); - $table->enum('status', ['draft', 'review', 'approved'])->default('draft'); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - $table->unique(['tenant_id', 'date', 'company_name'], 'pmis_dwr_unique'); - $table->index('tenant_id'); - }); - } - - public function down(): void - { - Schema::dropIfExists('pmis_daily_work_reports'); - } -}; diff --git a/database/migrations/2026_03_12_190001_create_pmis_work_report_details_tables.php b/database/migrations/2026_03_12_190001_create_pmis_work_report_details_tables.php deleted file mode 100644 index 1b0e952f..00000000 --- a/database/migrations/2026_03_12_190001_create_pmis_work_report_details_tables.php +++ /dev/null @@ -1,104 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id'); - $table->foreignId('report_id')->constrained('pmis_daily_work_reports')->cascadeOnDelete(); - $table->string('work_type', 200); - $table->string('job_type', 200); - $table->integer('prev_cumulative')->default(0); - $table->integer('today_count')->default(0); - $table->unsignedSmallInteger('sort_order')->default(0); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - $table->index('tenant_id'); - }); - - // 장비 - Schema::create('pmis_work_report_equipments', function (Blueprint $table) { - $table->id(); - $table->unsignedBigInteger('tenant_id'); - $table->foreignId('report_id')->constrained('pmis_daily_work_reports')->cascadeOnDelete(); - $table->string('equipment_name', 200); - $table->string('specification', 300)->default(''); - $table->integer('prev_cumulative')->default(0); - $table->integer('today_count')->default(0); - $table->unsignedSmallInteger('sort_order')->default(0); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - $table->index('tenant_id'); - }); - - // 자재 - Schema::create('pmis_work_report_materials', function (Blueprint $table) { - $table->id(); - $table->unsignedBigInteger('tenant_id'); - $table->foreignId('report_id')->constrained('pmis_daily_work_reports')->cascadeOnDelete(); - $table->string('material_name', 200); - $table->string('specification', 300)->default(''); - $table->string('unit', 50)->default(''); - $table->decimal('design_qty', 14, 2)->default(0); - $table->decimal('prev_cumulative', 14, 2)->default(0); - $table->decimal('today_count', 14, 2)->default(0); - $table->unsignedSmallInteger('sort_order')->default(0); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - $table->index('tenant_id'); - }); - - // 공사량 - Schema::create('pmis_work_report_volumes', function (Blueprint $table) { - $table->id(); - $table->unsignedBigInteger('tenant_id'); - $table->foreignId('report_id')->constrained('pmis_daily_work_reports')->cascadeOnDelete(); - $table->string('work_type', 200); - $table->string('sub_work_type', 200)->default(''); - $table->string('unit', 50)->default(''); - $table->decimal('design_qty', 14, 2)->default(0); - $table->decimal('prev_cumulative', 14, 2)->default(0); - $table->decimal('today_count', 14, 2)->default(0); - $table->unsignedSmallInteger('sort_order')->default(0); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - $table->index('tenant_id'); - }); - - // 작업사진 - Schema::create('pmis_work_report_photos', function (Blueprint $table) { - $table->id(); - $table->unsignedBigInteger('tenant_id'); - $table->foreignId('report_id')->constrained('pmis_daily_work_reports')->cascadeOnDelete(); - $table->string('photo_path', 500)->default(''); - $table->string('location', 200)->default(''); - $table->string('content', 500)->default(''); - $table->date('photo_date')->nullable(); - $table->unsignedSmallInteger('sort_order')->default(0); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - $table->index('tenant_id'); - }); - } - - public function down(): void - { - Schema::dropIfExists('pmis_work_report_photos'); - Schema::dropIfExists('pmis_work_report_volumes'); - Schema::dropIfExists('pmis_work_report_materials'); - Schema::dropIfExists('pmis_work_report_equipments'); - Schema::dropIfExists('pmis_work_report_workers'); - } -}; diff --git a/database/migrations/2026_03_12_203417_create_pmis_archive_tables.php b/database/migrations/2026_03_12_203417_create_pmis_archive_tables.php deleted file mode 100644 index 048748a0..00000000 --- a/database/migrations/2026_03_12_203417_create_pmis_archive_tables.php +++ /dev/null @@ -1,51 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id'); - $table->unsignedBigInteger('parent_id')->nullable(); - $table->string('name', 200); - $table->unsignedSmallInteger('sort_order')->default(0); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->index('tenant_id'); - $table->index('parent_id'); - }); - - Schema::create('pmis_archive_files', function (Blueprint $table) { - $table->id(); - $table->unsignedBigInteger('tenant_id'); - $table->foreignId('folder_id')->constrained('pmis_archive_folders')->cascadeOnDelete(); - $table->string('title', 300)->default(''); - $table->string('original_name', 500); - $table->string('file_path', 500); - $table->string('file_type', 50)->default('문서'); - $table->unsignedBigInteger('file_size')->default(0); - $table->string('site_name', 200)->default(''); - $table->unsignedBigInteger('registered_by')->nullable(); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->index('tenant_id'); - $table->index('folder_id'); - $table->index('file_type'); - }); - } - - public function down(): void - { - Schema::dropIfExists('pmis_archive_files'); - Schema::dropIfExists('pmis_archive_folders'); - } -}; diff --git a/database/migrations/2026_03_12_204558_create_pmis_manuals_table.php b/database/migrations/2026_03_12_204558_create_pmis_manuals_table.php deleted file mode 100644 index 7f5b07f5..00000000 --- a/database/migrations/2026_03_12_204558_create_pmis_manuals_table.php +++ /dev/null @@ -1,41 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id'); - $table->string('title', 300); - $table->text('content')->nullable(); - $table->string('tags', 500)->default(''); - $table->unsignedBigInteger('author_id')->nullable(); - $table->unsignedInteger('views')->default(0); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->index('tenant_id'); - }); - - Schema::create('pmis_manual_attachments', function (Blueprint $table) { - $table->id(); - $table->foreignId('manual_id')->constrained('pmis_manuals')->cascadeOnDelete(); - $table->string('original_name', 500); - $table->string('file_path', 500); - $table->unsignedBigInteger('file_size')->default(0); - $table->timestamps(); - }); - } - - public function down(): void - { - Schema::dropIfExists('pmis_manual_attachments'); - Schema::dropIfExists('pmis_manuals'); - } -}; diff --git a/database/migrations/2026_03_12_205226_create_pmis_notices_table.php b/database/migrations/2026_03_12_205226_create_pmis_notices_table.php deleted file mode 100644 index 86b3f480..00000000 --- a/database/migrations/2026_03_12_205226_create_pmis_notices_table.php +++ /dev/null @@ -1,40 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id'); - $table->string('title', 300); - $table->text('content')->nullable(); - $table->unsignedBigInteger('author_id')->nullable(); - $table->unsignedInteger('views')->default(0); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - - $table->index('tenant_id'); - }); - - Schema::create('pmis_notice_attachments', function (Blueprint $table) { - $table->id(); - $table->foreignId('notice_id')->constrained('pmis_notices')->cascadeOnDelete(); - $table->string('original_name', 500); - $table->string('file_path', 500); - $table->unsignedBigInteger('file_size')->default(0); - $table->timestamps(); - }); - } - - public function down(): void - { - Schema::dropIfExists('pmis_notice_attachments'); - Schema::dropIfExists('pmis_notices'); - } -}; diff --git a/database/migrations/2026_03_13_100000_fix_duplicate_journal_entry_lines.php b/database/migrations/2026_03_13_100000_fix_duplicate_journal_entry_lines.php deleted file mode 100644 index b70a02b6..00000000 --- a/database/migrations/2026_03_13_100000_fix_duplicate_journal_entry_lines.php +++ /dev/null @@ -1,92 +0,0 @@ - 1 - "); - - if (empty($duplicates)) { - Log::info('[Migration] 중복 journal_entry_lines 없음 - 정리 불필요'); - - return; - } - - $totalDeleted = 0; - - foreach ($duplicates as $dup) { - $allIds = explode(',', $dup->all_ids); - $keepId = $dup->keep_id; - $deleteIds = array_filter($allIds, fn ($id) => (int) $id !== (int) $keepId); - - if (! empty($deleteIds)) { - Log::info("[Migration] 중복 라인 삭제: journal_entry_id={$dup->journal_entry_id}, " - ."account_code={$dup->account_code}, dc_type={$dup->dc_type}, " - ."partner={$dup->trading_partner_name}, " - ."keep_id={$keepId}, delete_ids=".implode(',', $deleteIds)); - - $deleted = DB::table('journal_entry_lines') - ->whereIn('id', $deleteIds) - ->delete(); - - $totalDeleted += $deleted; - } - } - - Log::info("[Migration] 중복 journal_entry_lines 정리 완료: {$totalDeleted}건 삭제"); - - // 2. 삭제 후 전표 합계 재계산 - if ($totalDeleted > 0) { - $affectedEntryIds = collect($duplicates)->pluck('journal_entry_id')->unique(); - - foreach ($affectedEntryIds as $entryId) { - $sums = DB::selectOne(" - SELECT COALESCE(SUM(debit_amount), 0) as total_debit, - COALESCE(SUM(credit_amount), 0) as total_credit - FROM journal_entry_lines - WHERE journal_entry_id = ? - ", [$entryId]); - - DB::table('journal_entries') - ->where('id', $entryId) - ->update([ - 'total_debit' => $sums->total_debit, - 'total_credit' => $sums->total_credit, - ]); - - Log::info("[Migration] 전표 합계 재계산: id={$entryId}, " - ."debit={$sums->total_debit}, credit={$sums->total_credit}"); - } - } - } - - /** - * 데이터 정리 마이그레이션이므로 rollback 불가 - */ - public function down(): void - { - Log::warning('[Migration] 중복 라인 삭제는 롤백할 수 없습니다.'); - } -}; diff --git a/database/migrations/2026_03_13_180000_create_daily_work_logs_tables.php b/database/migrations/2026_03_13_180000_create_daily_work_logs_tables.php deleted file mode 100644 index dddb58d1..00000000 --- a/database/migrations/2026_03_13_180000_create_daily_work_logs_tables.php +++ /dev/null @@ -1,48 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id'); - $table->date('log_date'); - $table->text('memo')->nullable(); - $table->text('reflection')->nullable(); - $table->unsignedBigInteger('created_by')->nullable(); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - $table->unique(['tenant_id', 'log_date']); - $table->index('tenant_id'); - }); - - Schema::create('daily_work_log_items', function (Blueprint $table) { - $table->id(); - $table->unsignedBigInteger('tenant_id'); - $table->foreignId('daily_work_log_id')->constrained('daily_work_logs')->cascadeOnDelete(); - $table->unsignedSmallInteger('sort_order')->default(0); - $table->string('category', 100)->nullable(); - $table->string('task', 500); - $table->string('priority', 50)->nullable(); - $table->boolean('is_completed')->default(false); - $table->string('note', 500)->nullable(); - $table->json('options')->nullable(); - $table->timestamps(); - $table->softDeletes(); - $table->index('tenant_id'); - $table->index('daily_work_log_id'); - }); - } - - public function down(): void - { - Schema::dropIfExists('daily_work_log_items'); - Schema::dropIfExists('daily_work_logs'); - } -}; diff --git a/database/migrations/2026_03_17_112601_replace_codebridge_account_codes_with_kis_standard.php b/database/migrations/2026_03_17_112601_replace_codebridge_account_codes_with_kis_standard.php deleted file mode 100644 index 51971e0e..00000000 --- a/database/migrations/2026_03_17_112601_replace_codebridge_account_codes_with_kis_standard.php +++ /dev/null @@ -1,51 +0,0 @@ - 'asset', - '부채' => 'liability', - '자본' => 'capital', - '수익' => 'revenue', - '비용' => 'expense', - ]; - - foreach ($mapping as $korean => $english) { - DB::table('account_codes') - ->where('category', $korean) - ->update(['category' => $english]); - } - - // 2. tenant_id=1의 5자리가 아닌 코드 삭제 (1, 2, 3자리) - DB::table('account_codes') - ->where('tenant_id', 1) - ->whereRaw('LENGTH(code) != 5') - ->delete(); - - // 3. 5자리 코드 전체 활성화 - DB::table('account_codes') - ->where('tenant_id', 1) - ->whereRaw('LENGTH(code) = 5') - ->update(['is_active' => true]); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - // 롤백 불가 - } -}; diff --git a/database/migrations/2026_03_19_160707_migrate_3digit_to_5digit_account_codes.php b/database/migrations/2026_03_19_160707_migrate_3digit_to_5digit_account_codes.php deleted file mode 100644 index 0f5bbbd3..00000000 --- a/database/migrations/2026_03_19_160707_migrate_3digit_to_5digit_account_codes.php +++ /dev/null @@ -1,107 +0,0 @@ - '10100', // 현금 - '102' => '10200', // 당좌예금 - '103' => '10300', // 보통예금 - '105' => '10500', // 정기적금 - '108' => '10800', // 외상매출금 - '109' => '10900', // 대손충당금 → 대손충당금(외상매출금) - '117' => '13500', // 부가세대급금 - '135' => '13500', // 부가세대급금 (중복코드) - '157' => '96200', // 임차보증금 - '172' => '21200', // 비품 - '204' => '25300', // 미지급금 - '205' => '26200', // 미지급비용 - '207' => '25400', // 예수금 - '208' => '25500', // 부가세예수금 - '251' => '25100', // 외상매입금 - '253' => '25300', // 미지급금 - '301' => '33100', // 자본금 - '401' => '40100', // 상품매출 - '402' => '40400', // 제품매출 - '501' => '45100', // 상품매입 → 상품매출원가 - '801' => '80200', // 급여 → 직원급여 - '805' => '81100', // 복리후생비 - '807' => '81300', // 접대비 - '808' => '81400', // 통신비 - '811' => '81700', // 세금과공과 → 세금과공과금 - '812' => '81900', // 임차료 → 지급임차료 - '816' => '82100', // 보험료 - '817' => '82200', // 차량유지비 - '818' => '82400', // 운반비 - '820' => '82600', // 도서인쇄비 - '821' => '82900', // 사무용품비 - '822' => '83000', // 소모품비 - '823' => '83100', // 지급수수료 - '826' => '83700', // 건물관리비 - '838' => '83100', // 용역비 → 지급수수료 - '901' => '90100', // 이자수익 - ]; - - public function up(): void - { - $tables = ['journal_entry_lines', 'hometax_invoice_journals']; - - // 5자리 코드의 계정명 사전 구축 - $names = []; - foreach (self::MAPPING as $newCode) { - if (! isset($names[$newCode])) { - $ac = DB::table('account_codes') - ->where('code', $newCode) - ->first(['name']); - $names[$newCode] = $ac?->name; - } - } - - foreach ($tables as $table) { - // 3자리 이하 코드가 있는지 확인 - $has3digit = DB::table($table) - ->whereRaw('LENGTH(account_code) < 5') - ->exists(); - - if (! $has3digit) { - Log::info("[Migration] {$table}: 3자리 코드 없음, 건너뜀"); - - continue; - } - - foreach (self::MAPPING as $oldCode => $newCode) { - $newName = $names[$newCode] ?? null; - if (! $newName) { - continue; - } - - $updated = DB::table($table) - ->where('account_code', $oldCode) - ->update([ - 'account_code' => $newCode, - 'account_name' => $newName, - ]); - - if ($updated > 0) { - Log::info("[Migration] {$table}: {$oldCode} → {$newCode} ({$newName}): {$updated}건"); - } - } - } - } - - public function down(): void - { - // 역방향 마이그레이션은 지원하지 않음 (데이터 변환은 되돌리기 어려움) - } -};