2
0

004_createFileCategoryTable.ts 951 B

1234567891011121314151617181920212223242526
  1. import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
  2. import { DeleteStatus } from '../../client/share/types.ts'
  3. const createFileCategoryTable: MigrationLiveDefinition = {
  4. name: "create_file_category_table",
  5. up: async (api) => {
  6. await api.schema.createTable('file_categories', (table) => {
  7. table.increments('id').primary();
  8. table.string('name').notNullable().comment('分类名称');
  9. table.string('code').notNullable().unique().comment('分类编码');
  10. table.text('description').comment('分类描述');
  11. table.integer('is_deleted').defaultTo(DeleteStatus.NOT_DELETED).comment('是否被删除 (0否 1是)');
  12. table.timestamps(true, true);
  13. // 添加索引
  14. table.index('name');
  15. table.index('code');
  16. table.index('is_deleted');
  17. });
  18. },
  19. down: async (api) => {
  20. await api.schema.dropTable('file_categories');
  21. }
  22. }
  23. export default createFileCategoryTable;