2
0

003_createKnowInfoTable.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
  2. import { AuditStatus, DeleteStatus } from '../../client/share/types.ts'
  3. const createKnowInfoTable: MigrationLiveDefinition = {
  4. name: "create_know_info_table",
  5. up: async (api) => {
  6. await api.schema.createTable('know_info', (table) => {
  7. table.increments('id').primary();
  8. table.string('title').comment('文章标题');
  9. table.string('tags').comment('文章标签');
  10. table.text('content').comment('文章内容');
  11. table.string('author').comment('作者');
  12. table.string('category').comment('分类');
  13. table.string('cover_url').comment('封面图片URL');
  14. table.integer('audit_status').defaultTo(AuditStatus.PENDING).comment('审核状态');
  15. table.integer('sort_order').defaultTo(0).comment('排序权重');
  16. table.integer('is_deleted').defaultTo(DeleteStatus.NOT_DELETED).comment('是否被删除 (0否 1是)');
  17. table.timestamps(true, true);
  18. // 添加索引
  19. table.index('title');
  20. table.index('tags');
  21. table.index('author');
  22. table.index('category');
  23. table.index('audit_status');
  24. table.index('sort_order');
  25. table.index('is_deleted');
  26. });
  27. },
  28. down: async (api) => {
  29. await api.schema.dropTable('know_info');
  30. }
  31. }
  32. export default createKnowInfoTable;