Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(fe): hide rollback UI for engines without rollback support (#18889)

Danny Xu3436ccfd87a3
diff --git a/frontend/src/components/Changelog/ChangelogDetail.vue b/frontend/src/components/Changelog/ChangelogDetail.vue
index 59ba4d3e6d..a53315703c 100644
--- a/frontend/src/components/Changelog/ChangelogDetail.vue
+++ b/frontend/src/components/Changelog/ChangelogDetail.vue
@@ -143,6 +143,7 @@ import {
wrapRefAsPromise,
} from "@/utils";
import { getChangelogChangeType } from "@/utils/v1/changelog";
+import { instanceV1SupportsSchemaRollback } from "@/utils/v1/instance";
import ChangelogStatusIcon from "./ChangelogStatusIcon.vue";
interface LocalState {
@@ -232,11 +233,18 @@ const previousSchema = computed((): string => {
});
// Allow rollback for completed MIGRATE changelogs when user has alter schema permission
+// and the database engine supports schema diff rollback
const allowRollback = computed((): boolean => {
if (isDefaultProject.value) {
return false;
}
- if (!changelog.value || !allowAlterSchema.value) {
+ if (!changelog.value || !allowAlterSchema.value || !database.value) {
+ return false;
+ }
+ // Check if engine supports schema diff rollback (GenerateMigration in backend)
+ if (
+ !instanceV1SupportsSchemaRollback(database.value.instanceResource.engine)
+ ) {
return false;
}
return (
diff --git a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue
index 54e53f4861..89f6c7d657 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/PreBackupSection.vue
@@ -17,7 +17,7 @@ import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
import type { Plan } from "@/types/proto-es/v1/plan_service_pb";
import { TaskRun_Status } from "@/types/proto-es/v1/rollout_service_pb";
import { databaseForTask, hasProjectPermissionV2 } from "@/utils";
-import { ROLLBACK_AVAILABLE_ENGINES } from "./common";
+import { instanceV1SupportsPriorBackupRollback } from "@/utils/v1/instance";
import TaskRollbackSection from "./TaskRollbackSection.vue";
const { isCreating, issue, selectedTask, events } = useIssueContext();
@@ -77,7 +77,9 @@ const shouldShowTaskRollbackSection = computed((): boolean => {
return false;
}
if (
- !ROLLBACK_AVAILABLE_ENGINES.includes(database.value.instanceResource.engine)
+ !instanceV1SupportsPriorBackupRollback(
+ database.value.instanceResource.engine
+ )
) {
return false;
}
diff --git a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/common.ts b/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/common.ts
deleted file mode 100644
index 11c00ed3eb..0000000000
--- a/frontend/src/components/IssueV1/components/Sidebar/PreBackupSection/common.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Engine } from "@/types/proto-es/v1/common_pb";
-
-export const ROLLBACK_AVAILABLE_ENGINES = [
- Engine.MYSQL,
- Engine.POSTGRES,
- Engine.MSSQL,
- Engine.ORACLE,
-];
diff --git a/frontend/src/utils/v1/instance.ts b/frontend/src/utils/v1/instance.ts
index 8e00d4aee1..b1dda2ace0 100644
--- a/frontend/src/utils/v1/instance.ts
+++ b/frontend/src/utils/v1/instance.ts
@@ -473,3 +473,26 @@ export const getDefaultTransactionMode = (): boolean => {
// All engines default to "on" for safety and backward compatibility
return true;
};
+
+// Engines that support prior backup rollback (restore from backup)
+// These engines support GenerateRestoreSQL for DML rollback via backup restore
+export const instanceV1SupportsPriorBackupRollback = (
+ engine: Engine
+): boolean => {
+ return [Engine.MYSQL, Engine.POSTGRES, Engine.MSSQL, Engine.ORACLE].includes(
+ engine
+ );
+};
+
+// Engines that support schema diff rollback (generate reverse DDL via schema comparison)
+// These engines have RegisterGenerateMigration implemented in backend
+export const instanceV1SupportsSchemaRollback = (engine: Engine): boolean => {
+ return [
+ Engine.MYSQL,
+ Engine.OCEANBASE,
+ Engine.TIDB,
+ Engine.POSTGRES,
+ Engine.ORACLE,
+ Engine.MSSQL,
+ ].includes(engine);
+};