From 25db0df38be05999493dd30f2d06038840ea82ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=98=81=EB=B3=B4?= Date: Sat, 21 Mar 2026 15:39:09 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[=EC=A0=88=EA=B3=A1]=20bending=5Fmodels?= =?UTF-8?q?=20lot=5Fno=20=EC=A0=9C=EA=B1=B0=20=E2=80=94=20legacy=5Fcode?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EA=B4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - bending_models에는 LOT 개념 없음, lot_no 컬럼 불필요 - lot_no 값 → legacy_code로 이관 후 컬럼 DROP - BendingModel fillable에서 lot_no 제거 - GuiderailModelResource에서 lot_no 제거 - BendingModelImport: lot_no → legacy_code - 마이그레이션 rollback 로직 수정 --- app/Console/Commands/BendingModelImport.php | 2 +- .../Api/V1/GuiderailModelResource.php | 1 - app/Models/BendingModel.php | 2 +- ...rate_code_and_lot_no_in_bending_tables.php | 19 ++++++------------- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/app/Console/Commands/BendingModelImport.php b/app/Console/Commands/BendingModelImport.php index e5cd70f1..7c65a9ba 100644 --- a/app/Console/Commands/BendingModelImport.php +++ b/app/Console/Commands/BendingModelImport.php @@ -121,7 +121,7 @@ private function importModel(object $row, string $type, string $code, array $dat 'tenant_id' => $this->tenantId, 'model_type' => $type, 'code' => explode('-', $code)[0], - 'lot_no' => $code, + 'legacy_code' => $code, 'legacy_num' => $row->num, 'components' => $components, 'material_summary' => $materialSummary, diff --git a/app/Http/Resources/Api/V1/GuiderailModelResource.php b/app/Http/Resources/Api/V1/GuiderailModelResource.php index f77f4c34..ba94ab04 100644 --- a/app/Http/Resources/Api/V1/GuiderailModelResource.php +++ b/app/Http/Resources/Api/V1/GuiderailModelResource.php @@ -19,7 +19,6 @@ public function toArray(Request $request): array return [ 'id' => $this->id, 'code' => $this->code, - 'lot_no' => $this->lot_no, 'name' => $this->name, 'is_active' => $this->is_active, // MNG2 호환 diff --git a/app/Models/BendingModel.php b/app/Models/BendingModel.php index 742af838..cd72abe8 100644 --- a/app/Models/BendingModel.php +++ b/app/Models/BendingModel.php @@ -16,7 +16,7 @@ class BendingModel extends Model protected $table = 'bending_models'; protected $fillable = [ - 'tenant_id', 'model_type', 'code', 'lot_no', 'name', 'legacy_code', 'legacy_num', + 'tenant_id', 'model_type', 'code', 'name', 'legacy_code', 'legacy_num', 'model_name', 'model_UA', 'item_sep', 'finishing_type', 'author', 'remark', 'check_type', 'rail_width', 'rail_length', 'exit_direction', 'front_bottom_width', 'box_width', 'box_height', diff --git a/database/migrations/2026_03_21_100000_separate_code_and_lot_no_in_bending_tables.php b/database/migrations/2026_03_21_100000_separate_code_and_lot_no_in_bending_tables.php index 39aeee21..9da0525f 100644 --- a/database/migrations/2026_03_21_100000_separate_code_and_lot_no_in_bending_tables.php +++ b/database/migrations/2026_03_21_100000_separate_code_and_lot_no_in_bending_tables.php @@ -30,18 +30,14 @@ public function up(): void $table->index('code', 'idx_bending_code_type'); }); - // ── bending_models ── - Schema::table('bending_models', function (Blueprint $table) { - $table->string('lot_no', 100)->nullable()->after('code')->comment('전체 코드 (기존 code 값 이관)'); - }); - - // 기존 code → lot_no 이관, code에는 접두사만 남기기 (GR-, SB-, BB-) - DB::statement("UPDATE bending_models SET lot_no = code, code = CASE + // ── bending_models ── (lot_no 불필요, legacy_code에 이관) + DB::statement("UPDATE bending_models SET legacy_code = code WHERE legacy_code IS NULL"); + DB::statement("UPDATE bending_models SET code = CASE WHEN code LIKE 'GR-%' THEN 'GR' WHEN code LIKE 'SB-%' THEN 'SB' WHEN code LIKE 'BB-%' THEN 'BB' ELSE LEFT(code, 2) - END WHERE lot_no IS NULL"); + END WHERE code LIKE '%-%'"); } public function down(): void @@ -61,10 +57,7 @@ public function down(): void $table->dropColumn('lot_no'); }); - // bending_models: lot_no → code 복원 - DB::statement("UPDATE bending_models SET code = lot_no WHERE lot_no IS NOT NULL"); - Schema::table('bending_models', function (Blueprint $table) { - $table->dropColumn('lot_no'); - }); + // bending_models: legacy_code → code 복원 + DB::statement("UPDATE bending_models SET code = legacy_code WHERE legacy_code IS NOT NULL"); } };