增加 迁移回滚功能实现
This commit is contained in:
26
server/migrations/004_createFileCategoryTable.ts
Normal file
26
server/migrations/004_createFileCategoryTable.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
|
||||
import { DeleteStatus } from '../../client/share/types.ts'
|
||||
|
||||
const createFileCategoryTable: MigrationLiveDefinition = {
|
||||
name: "create_file_category_table",
|
||||
up: async (api) => {
|
||||
await api.schema.createTable('file_categories', (table) => {
|
||||
table.increments('id').primary();
|
||||
table.string('name').notNullable().comment('分类名称');
|
||||
table.string('code').notNullable().unique().comment('分类编码');
|
||||
table.text('description').comment('分类描述');
|
||||
table.integer('is_deleted').defaultTo(DeleteStatus.NOT_DELETED).comment('是否被删除 (0否 1是)');
|
||||
table.timestamps(true, true);
|
||||
|
||||
// 添加索引
|
||||
table.index('name');
|
||||
table.index('code');
|
||||
table.index('is_deleted');
|
||||
});
|
||||
},
|
||||
down: async (api) => {
|
||||
await api.schema.dropTable('file_categories');
|
||||
}
|
||||
}
|
||||
|
||||
export default createFileCategoryTable;
|
||||
Reference in New Issue
Block a user