029_add_work_order_fields.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
  2. const addWorkOrderFields: MigrationLiveDefinition = {
  3. name: 'add_work_order_fields',
  4. up: async (api) => {
  5. await api.schema.alterTable('work_orders', (table) => {
  6. table.string('order_no').nullable().comment('工单编号');
  7. table.integer('device_id').unsigned().nullable().comment('设备ID')
  8. .references('id').inTable('device_instances').onDelete('SET NULL');
  9. table.string('device_name').nullable().comment('设备名称');
  10. table.text('problem_desc').nullable().comment('问题描述');
  11. table.string('problem_type').nullable().comment('问题分类');
  12. table.text('feedback').nullable().comment('结果反馈');
  13. table.timestamp('deadline').nullable().comment('截止日期');
  14. table.index('order_no');
  15. table.index('device_id');
  16. table.index('problem_type');
  17. });
  18. },
  19. down: async (api) => {
  20. await api.schema.alterTable('work_orders', (table) => {
  21. table.dropColumn('order_no');
  22. table.dropColumn('device_id');
  23. table.dropColumn('device_name');
  24. table.dropColumn('problem_desc');
  25. table.dropColumn('problem_type');
  26. table.dropColumn('feedback');
  27. table.dropColumn('deadline');
  28. });
  29. }
  30. };
  31. export default addWorkOrderFields;