Skip to content

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

chore: update ghost checks for mariadb (#14018)

boojack555873920d03
diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
index 98f76a936f..872062484a 100644
--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
@@ -158,11 +158,11 @@ import { DatabaseMetadataView } from "@/types/proto/v1/database_service";
import { DatabaseChangeMode } from "@/types/proto/v1/setting_service";
import {
TinyTimer,
+ allowGhostMigrationV1,
defer,
extractProjectResourceName,
generateIssueTitle,
} from "@/utils";
-import { allowGhostForDatabase } from "../IssueV1/components/Sidebar/GhostSection/common";
import { MonacoEditor } from "../MonacoEditor";
import { provideSQLCheckContext } from "../SQLCheck";
import type { EditTarget, GenerateDiffDDLResult } from "../SchemaEditorLite";
@@ -270,7 +270,7 @@ const editTargetsKey = computed(() => {
const allowUseOnlineSchemaMigration = computed(() => {
return (
databaseChangeMode.value === DatabaseChangeMode.PIPELINE &&
- databaseList.value.every((db) => allowGhostForDatabase(db))
+ allowGhostMigrationV1(databaseList.value)
);
});
diff --git a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSection.vue b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSection.vue
index 82ff5edee7..d83ca55060 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSection.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSection.vue
@@ -15,8 +15,9 @@
class="whitespace-pre-line max-w-[20rem]"
>
<template #link>
+ <!-- TODO: update docs for mariadb -->
<LearnMoreLink
- url="https://www.bytebase.com/docs/change-database/online-schema-migration-for-mysql"
+ url="https://www.bytebase.com/docs/change-database/online-schema-migration-for-mysql?source=console"
color="light"
hide-when-embedded
/>
@@ -57,12 +58,15 @@ import FeatureBadgeForInstanceLicense from "@/components/FeatureGuard/FeatureBad
import { databaseForTask, useIssueContext } from "@/components/IssueV1/logic";
import LearnMoreLink from "@/components/LearnMoreLink.vue";
import { featureToRef } from "@/store";
-import { Engine } from "@/types/proto/v1/common";
import { flattenTaskV1List, isDatabaseChangeRelatedIssue } from "@/utils";
import GhostConfigButton from "./GhostConfigButton.vue";
import GhostFlagsPanel from "./GhostFlagsPanel.vue";
import GhostSwitch from "./GhostSwitch.vue";
-import { ghostViewTypeForTask, provideIssueGhostContext } from "./common";
+import {
+ allowGhostForDatabase,
+ ghostViewTypeForTask,
+ provideIssueGhostContext,
+} from "./common";
const { isCreating, issue, selectedTask: task } = useIssueContext();
@@ -79,12 +83,10 @@ const shouldShowGhostSection = computed(() => {
if (isCreating.value) {
// When an issue is pending create, we should show the gh-ost section
// whenever gh-ost is on or off.
- // But only show the gh-ost section when at least one of the tasks
- // is MySQL
return (
tasks.some((task) => {
const database = databaseForTask(issue.value, task);
- return database.instanceResource.engine === Engine.MYSQL;
+ return allowGhostForDatabase(database);
}) &&
tasks.every((task) => ghostViewTypeForTask(issue.value, task) !== "NONE")
);
diff --git a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSwitch.vue b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSwitch.vue
index b04bfc4489..558a9a0318 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSwitch.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSwitch.vue
@@ -39,6 +39,7 @@ import { default as ErrorList } from "@/components/misc/ErrorList.vue";
import { hasFeature } from "@/store";
import { Engine } from "@/types/proto/v1/common";
import {
+ MIN_GHOST_SUPPORT_MARIADB_VERSION,
MIN_GHOST_SUPPORT_MYSQL_VERSION,
engineNameV1,
flattenTaskV1List,
@@ -87,9 +88,7 @@ const errors = computed(() => {
)
);
errors.push({
- error: `${engineNameV1(
- Engine.MYSQL
- )} >= ${MIN_GHOST_SUPPORT_MYSQL_VERSION}`,
+ error: `${engineNameV1(Engine.MYSQL)} >= ${MIN_GHOST_SUPPORT_MYSQL_VERSION}, ${engineNameV1(Engine.MARIADB)} >= ${MIN_GHOST_SUPPORT_MARIADB_VERSION}`,
indent: 1,
});
}
diff --git a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts
index 2e4d1fe2a9..3c3eff9c22 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts
+++ b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/common.ts
@@ -25,6 +25,7 @@ import {
task_StatusToJSON,
} from "@/types/proto/v1/rollout_service";
import {
+ MIN_GHOST_SUPPORT_MARIADB_VERSION,
MIN_GHOST_SUPPORT_MYSQL_VERSION,
extractUserResourceName,
flattenTaskV1List,
@@ -162,13 +163,28 @@ export const allowChangeTaskGhostFlags = (issue: ComposedIssue, task: Task) => {
};
export const allowGhostForDatabase = (database: ComposedDatabase) => {
- return (
- database.instanceResource.engine === Engine.MYSQL &&
- semverCompare(
- database.instanceResource.engineVersion,
- MIN_GHOST_SUPPORT_MYSQL_VERSION,
- "gte"
+ if (
+ !useSubscriptionV1Store().hasInstanceFeature(
+ "bb.feature.online-migration",
+ database.instanceResource
)
+ ) {
+ return false;
+ }
+
+ return (
+ (database.instanceResource.engine === Engine.MYSQL &&
+ semverCompare(
+ database.instanceResource.engineVersion,
+ MIN_GHOST_SUPPORT_MYSQL_VERSION,
+ "gte"
+ )) ||
+ (database.instanceResource.engine === Engine.MARIADB &&
+ semverCompare(
+ database.instanceResource.engineVersion,
+ MIN_GHOST_SUPPORT_MARIADB_VERSION,
+ "gte"
+ ))
);
};
diff --git a/frontend/src/utils/v1/database.ts b/frontend/src/utils/v1/database.ts
index 5ada4a5668..059b66a64e 100644
--- a/frontend/src/utils/v1/database.ts
+++ b/frontend/src/utils/v1/database.ts
@@ -1,21 +1,17 @@
import { orderBy } from "lodash-es";
-import {
- checkQuerierPermission,
- hasFeature,
- useSubscriptionV1Store,
-} from "@/store";
+import { allowGhostForDatabase } from "@/components/IssueV1/components/Sidebar/GhostSection/common";
+import { checkQuerierPermission, hasFeature } from "@/store";
import {
databaseNamePrefix,
instanceNamePrefix,
} from "@/store/modules/v1/common";
import { UNKNOWN_ID } from "@/types";
import type { ComposedDatabase } from "@/types";
-import { Engine, State } from "@/types/proto/v1/common";
+import { State } from "@/types/proto/v1/common";
import {
hasPermissionToCreateChangeDatabaseIssue,
hasWorkspacePermissionV2,
} from "../iam";
-import { semverCompare } from "../util";
import { extractProjectResourceName } from "./project";
export const databaseV1Url = (db: ComposedDatabase) => {
@@ -156,22 +152,10 @@ export function filterDatabaseV1ByKeyword(
export const MIN_GHOST_SUPPORT_MYSQL_VERSION = "5.6.0";
+export const MIN_GHOST_SUPPORT_MARIADB_VERSION = "10.6.0";
+
export function allowGhostMigrationV1(
databaseList: ComposedDatabase[]
): boolean {
- const subscriptionV1Store = useSubscriptionV1Store();
- return databaseList.every((db) => {
- return (
- db.instanceResource.engine === Engine.MYSQL &&
- subscriptionV1Store.hasInstanceFeature(
- "bb.feature.online-migration",
- db.instanceResource
- ) &&
- semverCompare(
- db.instanceResource.engineVersion,
- MIN_GHOST_SUPPORT_MYSQL_VERSION,
- "gte"
- )
- );
- });
+ return databaseList.every((db) => allowGhostForDatabase(db));
}