Files
TK-FB-Project/api.hyungi.net/db/migrations/20260128010000_create_equipments_table.js
Hyungi Ahn e1227a69fe feat: 설비 관리 시스템 구축
## 주요 기능
- 설비 등록/수정/삭제 기능
- 작업장별 설비 연결
- 작업장 지도에서 설비 위치 정의
- 필터링 및 검색 기능

## 백엔드
- equipments 테이블 생성 (마이그레이션)
- 설비 API (모델, 컨트롤러, 라우트) 구현
- workplaces 테이블에 layout_image 컬럼 추가

## 프론트엔드
- 설비 관리 페이지 (equipments.html)
- 설비 관리 JavaScript (equipment-management.js)
- 작업장 지도 모달 개선

## 버그 수정
- 카테고리/작업장 이미지 보존 로직 개선 (null 처리)
- 작업장 레이아웃 이미지 업로드 경로 수정 (public/uploads → uploads)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-28 09:22:57 +09:00

49 lines
2.2 KiB
JavaScript

/**
* 설비 관리 테이블 생성
*
* @author TK-FB-Project
* @since 2026-01-28
*/
exports.up = async function(knex) {
await knex.schema.createTable('equipments', (table) => {
table.increments('equipment_id').primary().comment('설비 ID');
table.string('equipment_code', 50).notNullable().unique().comment('설비 코드 (예: CNC-01, LATHE-A)');
table.string('equipment_name', 100).notNullable().comment('설비명');
table.string('equipment_type', 50).nullable().comment('설비 유형 (예: CNC, 선반, 밀링 등)');
table.string('model_name', 100).nullable().comment('모델명');
table.string('manufacturer', 100).nullable().comment('제조사');
table.date('installation_date').nullable().comment('설치일');
table.string('serial_number', 100).nullable().comment('시리얼 번호');
table.text('specifications').nullable().comment('사양 정보 (JSON 형태로 저장 가능)');
table.enum('status', ['active', 'maintenance', 'inactive']).defaultTo('active').comment('설비 상태');
table.text('notes').nullable().comment('비고');
// 작업장 연결
table.integer('workplace_id').unsigned().nullable().comment('연결된 작업장 ID');
table.foreign('workplace_id').references('workplace_id').inTable('workplaces').onDelete('SET NULL');
// 지도상 위치 정보 (백분율 기반)
table.decimal('map_x_percent', 5, 2).nullable().comment('지도상 X 위치 (%)');
table.decimal('map_y_percent', 5, 2).nullable().comment('지도상 Y 위치 (%)');
table.decimal('map_width_percent', 5, 2).nullable().comment('지도상 영역 너비 (%)');
table.decimal('map_height_percent', 5, 2).nullable().comment('지도상 영역 높이 (%)');
// 타임스탬프
table.timestamp('created_at').defaultTo(knex.fn.now()).comment('생성일시');
table.timestamp('updated_at').defaultTo(knex.fn.now()).comment('수정일시');
// 인덱스
table.index('workplace_id');
table.index('equipment_type');
table.index('status');
});
console.log('✅ equipments 테이블 생성 완료');
};
exports.down = async function(knex) {
await knex.schema.dropTableIfExists('equipments');
console.log('✅ equipments 테이블 삭제 완료');
};