Skip to content

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

feat: feature guard for backward compatibility (#533)

ecmadao0b986558d0da
diff --git a/frontend/src/components/Issue/IssueDetailLayout.vue b/frontend/src/components/Issue/IssueDetailLayout.vue
index 9206fae2c1..3342ba9010 100644
--- a/frontend/src/components/Issue/IssueDetailLayout.vue
+++ b/frontend/src/components/Issue/IssueDetailLayout.vue
@@ -23,6 +23,24 @@
</IssueHighlightPanel>
</div>
+ <!-- Remind banner for bb.feature.backward-compatibility -->
+ <div
+ v-if="
+ !hasBackwardCompatibilityFeature && supportBackwardCompatibilityFeature
+ "
+ class="m-5 mt-0 p-2 rounded bg-yellow-300 text-gray-600"
+ >
+ <i18n-t
+ keypath="subscription.features.bb-feature-backward-compatibility.remind"
+ >
+ <template #upgrade>
+ <router-link to="/setting/subscription" class="normal-link">
+ {{ $t("subscription.upgrade") }}
+ </router-link>
+ </template>
+ </i18n-t>
+ </div>
+
<!-- Stage Flow Bar -->
<template v-if="showPipelineFlowBar">
<template v-if="isTenantDeployMode">
@@ -1048,6 +1066,17 @@ export default defineComponent({
document.getElementById("issue-detail-top")!.scrollIntoView();
});
+ const hasBackwardCompatibilityFeature = computed((): boolean => {
+ return store.getters["subscription/feature"](
+ "bb.feature.backward-compatibility"
+ );
+ });
+
+ const supportBackwardCompatibilityFeature = computed((): boolean => {
+ const engine = database.value?.instance.engine;
+ return engine === "MYSQL" || engine === "TIDB";
+ });
+
return {
database,
instance,
@@ -1096,6 +1125,8 @@ export default defineComponent({
showIssueTaskStatementPanel,
showIssueTaskRollbackStatementPanel,
showIssueTaskStatementApply,
+ hasBackwardCompatibilityFeature,
+ supportBackwardCompatibilityFeature,
};
},
});
diff --git a/frontend/src/locales/en.yml b/frontend/src/locales/en.yml
index d0c48656cf..782afd9f91 100644
--- a/frontend/src/locales/en.yml
+++ b/frontend/src/locales/en.yml
@@ -1152,3 +1152,6 @@ subscription:
bb-feature-multi-tenancy:
title: Multi-tenancy
desc: Intelligent database management for tenants using identical schemas.
+ bb-feature-backward-compatibility:
+ title: Backward compatibility
+ remind: MySQL and TiDB support schema change with backward compatibility. {upgrade} to open this feature.
diff --git a/frontend/src/locales/zh-CN.yml b/frontend/src/locales/zh-CN.yml
index 7a5a45c455..82ca5e1941 100644
--- a/frontend/src/locales/zh-CN.yml
+++ b/frontend/src/locales/zh-CN.yml
@@ -1021,3 +1021,6 @@ subscription:
bb-feature-multi-tenancy:
title: 多租户
desc: 「多租户功能」可以同时管理多个属于不同租户的同构数据库,帮您更统一和方便地对多个数据库进行管理和表结构变更。
+ bb-feature-backward-compatibility:
+ title: 向后兼容
+ remind: MySQL 和 TiDB 支持向后兼容的 schema 迁移,可以通过{upgrade}来开启该功能。
diff --git a/frontend/src/views/InstanceDashboard.vue b/frontend/src/views/InstanceDashboard.vue
index 04bfce8012..3c022b81e6 100644
--- a/frontend/src/views/InstanceDashboard.vue
+++ b/frontend/src/views/InstanceDashboard.vue
@@ -1,6 +1,6 @@
<template>
<div class="flex flex-col">
- <div class="m-5 p-2 rounded bg-yellow-300" v-if="remainingInstanceCount <= 3">
+ <div class="m-5 p-2 rounded bg-yellow-300 text-gray-600" v-if="remainingInstanceCount <= 3">
<i18n-t keypath="subscription.features.bb-feature-instance-count.remaining" v-if="remainingInstanceCount > 0">
<template v-slot:total>
<span class="text-accent">{{ instanceQuota }}</span>
diff --git a/server/task.go b/server/task.go
index 590acc7d3a..900603ae9c 100644
--- a/server/task.go
+++ b/server/task.go
@@ -195,20 +195,22 @@ func (s *Server) registerTaskRoutes(g *echo.Group) {
)
}
- _, err = s.TaskCheckRunService.CreateTaskCheckRunIfNeeded(ctx, &api.TaskCheckRunCreate{
- CreatorID: api.SystemBotID,
- TaskID: task.ID,
- Type: api.TaskCheckDatabaseStatementCompatibility,
- Payload: string(payload),
- SkipIfAlreadyTerminated: false,
- })
- if err != nil {
- // It's OK if we failed to trigger a check, just emit an error log
- s.l.Error("Failed to trigger compatibility check after changing task statement",
- zap.Int("task_id", task.ID),
- zap.String("task_name", task.Name),
- zap.Error(err),
- )
+ if s.feature(api.FeatureBackwardCompatibilty) {
+ _, err = s.TaskCheckRunService.CreateTaskCheckRunIfNeeded(ctx, &api.TaskCheckRunCreate{
+ CreatorID: api.SystemBotID,
+ TaskID: task.ID,
+ Type: api.TaskCheckDatabaseStatementCompatibility,
+ Payload: string(payload),
+ SkipIfAlreadyTerminated: false,
+ })
+ if err != nil {
+ // It's OK if we failed to trigger a check, just emit an error log
+ s.l.Error("Failed to trigger compatibility check after changing task statement",
+ zap.Int("task_id", task.ID),
+ zap.String("task_name", task.Name),
+ zap.Error(err),
+ )
+ }
}
}
}
diff --git a/server/task_check_executor_statement_advisor.go b/server/task_check_executor_statement_advisor.go
index d38dabae15..c54edfd373 100644
--- a/server/task_check_executor_statement_advisor.go
+++ b/server/task_check_executor_statement_advisor.go
@@ -37,6 +37,9 @@ func (exec *TaskCheckStatementAdvisorExecutor) Run(ctx context.Context, server *
case api.TaskCheckDatabaseStatementSyntax:
advisorType = advisor.MySQLSyntax
case api.TaskCheckDatabaseStatementCompatibility:
+ if !server.feature(api.FeatureBackwardCompatibilty) {
+ return []api.TaskCheckResult{}, common.Errorf(common.NotAuthorized, fmt.Errorf(api.FeatureBackwardCompatibilty.AccessErrorMessage()))
+ }
advisorType = advisor.MySQLMigrationCompatibility
}
diff --git a/server/task_check_scheduler.go b/server/task_check_scheduler.go
index 637a1a0de8..1c21b889e6 100644
--- a/server/task_check_scheduler.go
+++ b/server/task_check_scheduler.go
@@ -318,15 +318,17 @@ func (s *TaskCheckScheduler) ScheduleCheckIfNeeded(ctx context.Context, task *ap
return nil, err
}
- _, err = s.server.TaskCheckRunService.CreateTaskCheckRunIfNeeded(ctx, &api.TaskCheckRunCreate{
- CreatorID: creatorID,
- TaskID: task.ID,
- Type: api.TaskCheckDatabaseStatementCompatibility,
- Payload: string(payload),
- SkipIfAlreadyTerminated: skipIfAlreadyTerminated,
- })
- if err != nil {
- return nil, err
+ if s.server.feature(api.FeatureBackwardCompatibilty) {
+ _, err = s.server.TaskCheckRunService.CreateTaskCheckRunIfNeeded(ctx, &api.TaskCheckRunCreate{
+ CreatorID: creatorID,
+ TaskID: task.ID,
+ Type: api.TaskCheckDatabaseStatementCompatibility,
+ Payload: string(payload),
+ SkipIfAlreadyTerminated: skipIfAlreadyTerminated,
+ })
+ if err != nil {
+ return nil, err
+ }
}
}
diff --git a/server/task_scheduler.go b/server/task_scheduler.go
index f2d9c4087c..af501ab6ae 100644
--- a/server/task_scheduler.go
+++ b/server/task_scheduler.go
@@ -282,12 +282,14 @@ func (s *TaskScheduler) ScheduleIfNeeded(ctx context.Context, task *api.Task) (*
return task, nil
}
- pass, err = s.server.passCheck(ctx, s.server, task, api.TaskCheckDatabaseStatementCompatibility)
- if err != nil {
- return nil, err
- }
- if !pass {
- return task, nil
+ if s.server.feature(api.FeatureBackwardCompatibilty) {
+ pass, err = s.server.passCheck(ctx, s.server, task, api.TaskCheckDatabaseStatementCompatibility)
+ if err != nil {
+ return nil, err
+ }
+ if !pass {
+ return task, nil
+ }
}
}
}