/** * 설비 관리 테이블 생성 * * @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 테이블 삭제 완료'); };