迁移/回滚操作后的自动刷新
This commit is contained in:
@@ -47,6 +47,9 @@ const MigrationsApp: React.FC = () => {
|
||||
|
||||
const response = await axios.get('/api/migrations');
|
||||
setMigrationResult(response.data);
|
||||
if (response.data.success) {
|
||||
queryClient.invalidateQueries({ queryKey: ['migrations-history'] });
|
||||
}
|
||||
} catch (error: any) {
|
||||
setMigrationResult({
|
||||
success: false,
|
||||
@@ -65,6 +68,9 @@ const MigrationsApp: React.FC = () => {
|
||||
|
||||
const response = await axios.get(`/api/migrations/rollback?all=${all}`);
|
||||
setMigrationResult(response.data);
|
||||
if (response.data.success) {
|
||||
queryClient.invalidateQueries({ queryKey: ['migrations-history'] });
|
||||
}
|
||||
} catch (error: any) {
|
||||
setMigrationResult({
|
||||
success: false,
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
|
||||
|
||||
import {
|
||||
EnableStatus, DeleteStatus,
|
||||
AuditStatus, ThemeMode, FontSize, CompactMode,
|
||||
SystemSettingKey,
|
||||
SystemSettingGroup,
|
||||
ALLOWED_FILE_TYPES,
|
||||
} from '../client/share/types.ts';
|
||||
|
||||
// 动态加载迁移文件
|
||||
const migrations: MigrationLiveDefinition[] = [];
|
||||
|
||||
try {
|
||||
// 读取并加载所有迁移文件
|
||||
const migrationsDir = './server/migrations';
|
||||
const migrationsDir = import.meta.dirname + '/migrations';
|
||||
|
||||
for await (const entry of Deno.readDir(migrationsDir)) {
|
||||
if (!entry.isFile || !entry.name.endsWith('.ts')) continue;
|
||||
|
||||
@@ -279,12 +279,12 @@ const seedInitialData: MigrationLiveDefinition = {
|
||||
]);
|
||||
},
|
||||
down: async (api) => {
|
||||
// 删除初始数据
|
||||
await api.table('login_history').where('user_id', 1).delete();
|
||||
await api.table('theme_settings').where('user_id', 1).delete();
|
||||
await api.table('know_info').delete();
|
||||
await api.table('file_categories').delete();
|
||||
await api.table('users').where('username', 'admin').delete();
|
||||
// // 删除初始数据
|
||||
// await api.table('login_history').where('user_id', 1).delete();
|
||||
// await api.table('theme_settings').where('user_id', 1).delete();
|
||||
// await api.table('know_info').delete();
|
||||
// await api.table('file_categories').delete();
|
||||
// await api.table('users').where('username', 'admin').delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user