Skip to content

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

feat(frontend): support oracle schema tenant mode (#7026)

Liu Ji7167f7dd99f6
diff --git a/frontend/src/components/InstanceForm/InstanceForm.vue b/frontend/src/components/InstanceForm/InstanceForm.vue
index 59e722d2c2..1cbb8e5805 100644
--- a/frontend/src/components/InstanceForm/InstanceForm.vue
+++ b/frontend/src/components/InstanceForm/InstanceForm.vue
@@ -115,6 +115,13 @@
/>
</div>
+ <OracleSyncModeInput
+ v-if="basicInfo.engine === Engine.ORACLE"
+ :schema-tenant-mode="basicInfo.options?.schemaTenantMode ?? false"
+ :allow-edit="allowEdit"
+ @update:schema-tenant-mode="changeSyncMode"
+ />
+
<div class="sm:col-span-3 sm:col-start-1">
<template v-if="basicInfo.engine !== Engine.SPANNER">
<label for="host" class="textlabel block">
@@ -669,6 +676,7 @@ import {
} from "@/store";
import { getErrorCode, extractGrpcErrorMessage } from "@/utils/grpcweb";
import EnvironmentSelect from "@/components/EnvironmentSelect.vue";
+import OracleSyncModeInput from "./OracleSyncModeInput.vue";
import SslCertificateForm from "./SslCertificateForm.vue";
import SshConnectionForm from "./SshConnectionForm.vue";
import SpannerHostInput from "./SpannerHostInput.vue";
@@ -681,6 +689,7 @@ import {
DataSource,
DataSourceType,
Instance,
+ InstanceOptions,
} from "@/types/proto/v1/instance_service";
import { Engine, State } from "@/types/proto/v1/common";
import { instanceServiceClient } from "@/grpcweb";
@@ -781,6 +790,9 @@ const extractBasicInfo = (instance: Instance | undefined): BasicInfo => {
? instance.activation
: subscriptionStore.currentPlan !== PlanType.FREE &&
availableLicenseCount.value > 0,
+ options: instance?.options ?? {
+ schemaTenantMode: true, // default to true
+ },
};
};
@@ -1100,6 +1112,13 @@ const changeInstanceEngine = (engine: Engine) => {
basicInfo.value.engine = engine;
};
+const changeSyncMode = (schemaTenantMode: boolean) => {
+ if (!basicInfo.value.options) {
+ basicInfo.value.options = InstanceOptions.fromJSON({});
+ }
+ basicInfo.value.options.schemaTenantMode = schemaTenantMode;
+};
+
const trimInputValue = (target: Event["target"]) => {
return ((target as HTMLInputElement)?.value ?? "").trim();
};
@@ -1365,6 +1384,12 @@ const doUpdate = async () => {
if (instancePatch.activation !== instance.activation) {
updateMask.push("activation");
}
+ if (
+ instancePatch.options?.schemaTenantMode !==
+ instance.options?.schemaTenantMode
+ ) {
+ updateMask.push("options.schema_tenant_mode");
+ }
return await instanceV1Store.updateInstance(instancePatch, updateMask);
};
const updateDataSource = async (
diff --git a/frontend/src/components/InstanceForm/OracleSyncModeInput.vue b/frontend/src/components/InstanceForm/OracleSyncModeInput.vue
new file mode 100644
index 0000000000..855957e094
--- /dev/null
+++ b/frontend/src/components/InstanceForm/OracleSyncModeInput.vue
@@ -0,0 +1,81 @@
+<template>
+ <div class="sm:col-span-3 sm:col-start-1 flex flex-col gap-y-2">
+ <label class="textlabel">
+ {{ $t("instance.sync-mode.self") }}
+ </label>
+ <div class="flex items-center gap-x-4">
+ <label class="radio">
+ <input
+ v-model="state.mode"
+ tabindex="-1"
+ type="radio"
+ class="text-accent disabled:text-accent-disabled focus:ring-accent"
+ value="SYNC_SELF"
+ :disabled="!allowEdit"
+ />
+ <span class="label">
+ {{ $t("instance.sync-mode.sync-self") }}
+ </span>
+ </label>
+ <label class="radio">
+ <input
+ v-model="state.mode"
+ tabindex="-1"
+ type="radio"
+ class="text-accent disabled:text-accent-disabled focus:ring-accent"
+ value="SYNC_ALL"
+ :disabled="!allowEdit"
+ />
+ <span class="label">
+ {{ $t("instance.sync-mode.sync-all") }}
+ </span>
+ </label>
+ </div>
+
+ <label v-if="state.mode === 'SYNC_ALL'" class="textinfolabel">
+ {{ $t("instance.sync-mode.description") }}
+ </label>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { reactive, watch } from "vue";
+
+type SyncMode = "SYNC_SELF" | "SYNC_ALL";
+
+type LocalState = {
+ mode: SyncMode;
+};
+
+const props = defineProps<{
+ schemaTenantMode: boolean;
+ allowEdit: boolean;
+}>();
+
+const emit = defineEmits<{
+ (name: "update:schemaTenantMode", value: boolean): void;
+}>();
+
+const guessModeFromSchemaTenantMode = (schemaTenantMode: boolean): SyncMode => {
+ if (schemaTenantMode) return "SYNC_SELF";
+ return "SYNC_ALL";
+};
+
+const state = reactive<LocalState>({
+ mode: guessModeFromSchemaTenantMode(props.schemaTenantMode),
+});
+
+const update = (mode: SyncMode) => {
+ emit("update:schemaTenantMode", mode === "SYNC_SELF" ? true : false);
+};
+
+watch(
+ [() => props.schemaTenantMode],
+ ([schemaTenantMode]) => {
+ state.mode = guessModeFromSchemaTenantMode(schemaTenantMode);
+ },
+ { immediate: true }
+);
+
+watch(() => state.mode, update);
+</script>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 2d9419d950..44154965ef 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -972,7 +972,13 @@
"create-gcp-credentials": "To create Credentials, see",
"used-for-testing-connection": "Used for testing connections only",
"all": "All instances",
- "force-archive-description": "Force to archive. All releated issues will be resolved, and all related sheets will be deleted."
+ "force-archive-description": "Force to archive. All releated issues will be resolved, and all related sheets will be deleted.",
+ "sync-mode": {
+ "self": "Sync Mode",
+ "sync-self": "Sync self",
+ "sync-all": "Sync self and all containing databases (CDB + PDB)",
+ "description": "Bytebase will sync the connecting database as well as its all containing databases. Only applicable to Oracle 12c+."
+ }
},
"environment": {
"id": "Environment ID",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 65a7fcda6f..571ca7e3ed 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -972,7 +972,13 @@
"create-gcp-credentials": "Para crear credenciales, consulte",
"used-for-testing-connection": "Usado solo para probar conexiones",
"all": "Todas las instancias",
- "force-archive-description": "Forzar a archivar. \nTodos los problemas relacionados se resolverán y todas las hojas relacionadas se eliminarán."
+ "force-archive-description": "Forzar a archivar. \nTodos los problemas relacionados se resolverán y todas las hojas relacionadas se eliminarán.",
+ "sync-mode": {
+ "self": "Modo de sincronización",
+ "sync-self": "Sincronizarse",
+ "sync-all": "Sincronización propia y de todas las bases de datos (CDB + PDB)",
+ "description": "Bytebase sincronizará la base de datos de conexión, así como todas las bases de datos que la contienen. Solo aplicable a Oracle 12c."
+ }
},
"environment": {
"id": "ID del Entorno",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 85da44282e..e729e89892 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -969,7 +969,13 @@
"create-gcp-credentials": "创建凭据的方法见",
"used-for-testing-connection": "仅作测试连接用",
"all": "所有实例",
- "force-archive-description": "强制归档。所有关联的工单都将被解决,所有关联的工作表都将被删除。"
+ "force-archive-description": "强制归档。所有关联的工单都将被解决,所有关联的工作表都将被删除。",
+ "sync-mode": {
+ "self": "同步模式",
+ "sync-self": "同步自身",
+ "sync-all": "同步自身和所有包含的数据库(CDB + PDB)",
+ "description": "Bytebase 会同步连接数据库及其所有包含的数据库。仅适用于Oracle 12c。"
+ }
},
"environment": {
"id": "环境 ID",