/** * 설비 테이블에 구입처 및 구입가격 컬럼 추가 * * @author TK-FB-Project * @since 2026-02-04 */ exports.up = async function(knex) { // 컬럼 존재 여부 확인 const hasSupplier = await knex.schema.hasColumn('equipments', 'supplier'); const hasPurchasePrice = await knex.schema.hasColumn('equipments', 'purchase_price'); if (!hasSupplier || !hasPurchasePrice) { await knex.schema.alterTable('equipments', (table) => { if (!hasSupplier) { table.string('supplier', 100).nullable().after('manufacturer').comment('구입처'); } if (!hasPurchasePrice) { table.decimal('purchase_price', 15, 0).nullable().after('supplier').comment('구입가격'); } }); console.log('✅ equipments 테이블에 supplier, purchase_price 컬럼 추가 완료'); } else { console.log('ℹ️ supplier, purchase_price 컬럼이 이미 존재합니다. 스킵합니다.'); } }; exports.down = async function(knex) { await knex.schema.alterTable('equipments', (table) => { table.dropColumn('supplier'); table.dropColumn('purchase_price'); }); console.log('✅ equipments 테이블에서 supplier, purchase_price 컬럼 삭제 완료'); };