014_createZichanTransLogTable.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
  2. import { DeleteStatus } from "../../client/share/types.ts";
  3. import { DisabledStatus } from "../../client/share/monitorTypes.ts";
  4. // 定义资产流转表迁移
  5. const createZichanTransLogTable: MigrationLiveDefinition = {
  6. name: "create_zichan_trans_log_table",
  7. up: async (api) => {
  8. await api.schema.createTable('zichan_trans_log', (table) => {
  9. table.increments('id').primary();
  10. table.integer('asset_transfer').comment('资产流转类型');
  11. table.integer('asset_id').unsigned().references('id').inTable('zichan_info').onDelete('CASCADE').comment('资产ID');
  12. table.string('person').comment('人员');
  13. table.string('department').comment('部门');
  14. table.string('phone').comment('电话');
  15. table.text('transfer_reason').comment('流转事由');
  16. table.timestamp('transfer_time').comment('流转时间');
  17. table.integer('is_disabled').defaultTo(DisabledStatus.ENABLED).comment('是否被禁用 (0否 1是)');
  18. table.integer('is_deleted').defaultTo(DeleteStatus.NOT_DELETED).comment('是否被删除 (0否 1是)');
  19. table.timestamps(true, true);
  20. // 添加索引
  21. table.index('asset_id');
  22. table.index('asset_transfer');
  23. table.index('transfer_time');
  24. table.index('is_deleted');
  25. });
  26. },
  27. down: async (api) => {
  28. await api.schema.dropTable('zichan_trans_log');
  29. }
  30. };
  31. export default createZichanTransLogTable