fix: [절곡] bending_models lot_no 제거 — legacy_code로 이관
- bending_models에는 LOT 개념 없음, lot_no 컬럼 불필요 - lot_no 값 → legacy_code로 이관 후 컬럼 DROP - BendingModel fillable에서 lot_no 제거 - GuiderailModelResource에서 lot_no 제거 - BendingModelImport: lot_no → legacy_code - 마이그레이션 rollback 로직 수정
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 호환
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user