import type { MigrationLiveDefinition } from '@d8d-appcontainer/types' const addInspectionTaskFields: MigrationLiveDefinition = { name: 'add_inspection_task_fields', up: async (api) => { await api.schema.alterTable('inspection_tasks', (table) => { table.string('schedule_type').notNullable().defaultTo('manual').comment('调度类型: manual(手动)/scheduled(定时)'); table.string('cron_expression').nullable().comment('定时任务的cron表达式,当schedule_type为scheduled时必填'); table.jsonb('device_types').nullable().comment('设备类型筛选,JSON数组格式'); table.boolean('run_immediately').defaultTo(false).comment('是否立即执行,手动任务通常设为true'); table.boolean('is_new_year').defaultTo(false).comment('是否新年巡检'); table.integer('progress').defaultTo(0).comment('巡检进度百分比'); table.string('recipient_id').nullable().comment('接收人ID'); }); }, down: async (api) => { await api.schema.alterTable('inspection_tasks', (table) => { table.dropColumn('schedule_type'); table.dropColumn('cron_expression'); table.dropColumn('device_types'); table.dropColumn('run_immediately'); table.dropColumn('is_new_year'); table.dropColumn('progress'); table.dropColumn('recipient_id'); }); } }; export default addInspectionTaskFields