026_add_inspection_task_fields.ts 1.4 KB

1234567891011121314151617181920212223242526272829
  1. import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
  2. const addInspectionTaskFields: MigrationLiveDefinition = {
  3. name: 'add_inspection_task_fields',
  4. up: async (api) => {
  5. await api.schema.alterTable('inspection_tasks', (table) => {
  6. table.string('schedule_type').notNullable().defaultTo('manual').comment('调度类型: manual(手动)/scheduled(定时)');
  7. table.string('cron_expression').nullable().comment('定时任务的cron表达式,当schedule_type为scheduled时必填');
  8. table.jsonb('device_types').nullable().comment('设备类型筛选,JSON数组格式');
  9. table.boolean('run_immediately').defaultTo(false).comment('是否立即执行,手动任务通常设为true');
  10. table.boolean('is_new_year').defaultTo(false).comment('是否新年巡检');
  11. table.integer('progress').defaultTo(0).comment('巡检进度百分比');
  12. table.string('recipient_id').nullable().comment('接收人ID');
  13. });
  14. },
  15. down: async (api) => {
  16. await api.schema.alterTable('inspection_tasks', (table) => {
  17. table.dropColumn('schedule_type');
  18. table.dropColumn('cron_expression');
  19. table.dropColumn('device_types');
  20. table.dropColumn('run_immediately');
  21. table.dropColumn('is_new_year');
  22. table.dropColumn('progress');
  23. table.dropColumn('recipient_id');
  24. });
  25. }
  26. };
  27. export default addInspectionTaskFields