增加 迁移回滚功能实现

This commit is contained in:
yourname
2025-05-13 13:22:50 +00:00
parent 976e79894a
commit 8530fb5da6
13 changed files with 649 additions and 529 deletions

View File

@@ -0,0 +1,35 @@
import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
import { AuditStatus, DeleteStatus } from '../../client/share/types.ts'
const createKnowInfoTable: MigrationLiveDefinition = {
name: "create_know_info_table",
up: async (api) => {
await api.schema.createTable('know_info', (table) => {
table.increments('id').primary();
table.string('title').comment('文章标题');
table.string('tags').comment('文章标签');
table.text('content').comment('文章内容');
table.string('author').comment('作者');
table.string('category').comment('分类');
table.string('cover_url').comment('封面图片URL');
table.integer('audit_status').defaultTo(AuditStatus.PENDING).comment('审核状态');
table.integer('sort_order').defaultTo(0).comment('排序权重');
table.integer('is_deleted').defaultTo(DeleteStatus.NOT_DELETED).comment('是否被删除 (0否 1是)');
table.timestamps(true, true);
// 添加索引
table.index('title');
table.index('tags');
table.index('author');
table.index('category');
table.index('audit_status');
table.index('sort_order');
table.index('is_deleted');
});
},
down: async (api) => {
await api.schema.dropTable('know_info');
}
}
export default createKnowInfoTable;