import type { MigrationLiveDefinition } from '@d8d-appcontainer/types' import { DeleteStatus , EnableStatus} from "../../client/share/types.ts"; // 机柜信息表迁移 const createRackInfoTable: MigrationLiveDefinition = { name: "create_rack_info_table", up: async (api) => { await api.schema.createTable('rack_info', (table) => { table.increments('id').primary(); table.string('rack_name').comment('机柜名称'); table.string('rack_code').unique().comment('机柜编号'); table.integer('capacity').defaultTo(42).comment('机柜可容纳设备数量,默认42U'); table.decimal('position_x', 10, 6).comment('机柜X轴位置坐标'); table.decimal('position_y', 10, 6).comment('机柜Y轴位置坐标'); table.decimal('position_z', 10, 6).comment('机柜Z轴位置坐标'); table.string('area').comment('机柜所在区域'); table.string('room').comment('机柜所在机房'); table.text('remark').comment('备注信息'); table.integer('is_disabled').defaultTo(EnableStatus.ENABLED).comment('是否禁用 (0否 1是)'); table.integer('is_deleted').defaultTo(DeleteStatus.NOT_DELETED).comment('是否被删除 (0否 1是)'); table.timestamps(true, true); // 添加索引 table.index('rack_name'); table.index('rack_code'); table.index('area'); table.index('room'); table.index('is_disabled'); table.index('is_deleted'); }); }, down: async (api) => { await api.schema.dropTable('rack_info'); } }; export default createRackInfoTable