增加 迁移回滚功能实现

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,21 @@
import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
const createThemeSettingsTable: MigrationLiveDefinition = {
name: "create_theme_settings_table",
up: async (api) => {
await api.schema.createTable('theme_settings', (table) => {
table.increments('id').primary();
table.integer('user_id').unsigned().references('id').inTable('users').onDelete('CASCADE');
table.jsonb('settings').comment('主题设置');
table.timestamps(true, true);
// 添加索引
table.index('user_id');
});
},
down: async (api) => {
await api.schema.dropTable('theme_settings');
}
}
export default createThemeSettingsTable;