import type { MigrationLiveDefinition } from '@d8d-appcontainer/types' import { DeleteStatus, EnableStatus} from "../../client/share/types.ts"; // 告警处理记录表迁移 const createAlertHandleLogsTable: MigrationLiveDefinition = { name: 'create_alert_handle_logs_table', up: async (api) => { await api.schema.createTable('alert_handle_logs', (table) => { table.increments('id').primary(); table.integer('alert_id').unsigned().comment('关联的告警ID') .references('id').inTable('device_alerts').onDelete('CASCADE'); table.integer('handler_id').unsigned().comment('处理人ID') .references('id').inTable('users').onDelete('SET NULL'); table.string('handle_type').comment('处理类型'); table.string('problem_type').comment('问题类型'); table.text('handle_result').nullable().comment('处理结果'); table.jsonb('attachments').nullable().comment('附件列表'); table.integer('notify_disabled').defaultTo(0).comment('是否禁用通知 (0否 1是)'); table.jsonb('notify_items').nullable().comment('禁用的通知项配置'); table.timestamp('handle_time').comment('处理时间'); table.integer('is_deleted').defaultTo(DeleteStatus.NOT_DELETED).comment('是否删除 (0否 1是)'); table.timestamps(true, true); // 添加索引 table.index('alert_id'); table.index('handler_id'); table.index('handle_type'); table.index('problem_type'); table.index('handle_time'); table.index('is_deleted'); }); }, down: async (api) => { await api.schema.dropTable('alert_handle_logs'); } }; export default createAlertHandleLogsTable