增加 迁移回滚功能实现
This commit is contained in:
@@ -58,6 +58,24 @@ const MigrationsApp: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const rollbackMigrations = async (all: boolean) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
setMigrationResult(null);
|
||||
|
||||
const response = await axios.get(`/api/migrations/rollback?all=${all}`);
|
||||
setMigrationResult(response.data);
|
||||
} catch (error: any) {
|
||||
setMigrationResult({
|
||||
success: false,
|
||||
error: error.response?.data?.error || '数据库回滚失败',
|
||||
failedResult: error.response?.data?.failedResult
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: '迁移名称',
|
||||
@@ -93,14 +111,39 @@ const MigrationsApp: React.FC = () => {
|
||||
<Title level={3}>数据库迁移管理</Title>
|
||||
|
||||
<Space direction="vertical" size="middle" style={{ width: '100%' }}>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={runMigrations}
|
||||
loading={loading}
|
||||
disabled={loading}
|
||||
>
|
||||
执行迁移
|
||||
</Button>
|
||||
<Space>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={runMigrations}
|
||||
loading={loading}
|
||||
disabled={loading}
|
||||
>
|
||||
执行迁移
|
||||
</Button>
|
||||
<Button
|
||||
danger
|
||||
onClick={() => rollbackMigrations(false)}
|
||||
loading={loading}
|
||||
disabled={loading}
|
||||
>
|
||||
回滚最近一次
|
||||
</Button>
|
||||
<Button
|
||||
danger
|
||||
onClick={() => rollbackMigrations(true)}
|
||||
loading={loading}
|
||||
disabled={loading}
|
||||
>
|
||||
回滚全部
|
||||
</Button>
|
||||
</Space>
|
||||
<Alert
|
||||
message="警告"
|
||||
description="回滚操作将删除数据,请谨慎使用"
|
||||
type="warning"
|
||||
showIcon
|
||||
style={{ marginBottom: 16 }}
|
||||
/>
|
||||
|
||||
{loading && <Spin tip="迁移执行中..." />}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user