增加 迁移回滚功能实现

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,30 @@
import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
import { DeleteStatus } from '../../client/share/types.ts'
const createUsersTable: MigrationLiveDefinition = {
name: "create_users_table",
up: async (api) => {
await api.schema.createTable('users', (table) => {
table.increments('id').primary();
table.string('username').unique().notNullable();
table.string('password').notNullable();
table.string('phone').unique();
table.string('email').unique();
table.string('nickname');
table.string('name');
table.integer('is_disabled').defaultTo(DeleteStatus.NOT_DELETED);
table.integer('is_deleted').defaultTo(DeleteStatus.NOT_DELETED);
table.timestamps(true, true);
// 添加索引
table.index('username');
table.index('is_disabled');
table.index('is_deleted');
});
},
down: async (api) => {
await api.schema.dropTable('users');
}
}
export default createUsersTable;