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