Skip to content

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

chore: register ob for schema viewer (#11523)

boojack279e2c7b71ab
diff --git a/backend/plugin/schema/mysql/get_design_schema.go b/backend/plugin/schema/mysql/get_design_schema.go
index edba93e7e4..9315a1db31 100644
--- a/backend/plugin/schema/mysql/get_design_schema.go
+++ b/backend/plugin/schema/mysql/get_design_schema.go
@@ -20,6 +20,7 @@ import (
func init() {
schema.RegisterGetDesignSchema(storepb.Engine_MYSQL, GetDesignSchema)
+ schema.RegisterGetDesignSchema(storepb.Engine_OCEANBASE, GetDesignSchema)
}
func GetDesignSchema(_, baselineSchema string, to *storepb.DatabaseSchemaMetadata) (string, error) {
diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx
index 3ccdce6ce8..fb9cd400a8 100644
--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx
+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/actions.tsx
@@ -37,6 +37,12 @@ type DropdownOptionWithTreeNode = DropdownOption & {
onSelect: () => void;
};
const SELECT_ALL_LIMIT = 50; // default pagesize of SQL Editor
+const VIEW_SCHEMA_ACTION_ENABLED_ENGINES = [
+ Engine.MYSQL,
+ Engine.OCEANBASE,
+ Engine.POSTGRES,
+ Engine.TIDB,
+];
export const useDropdown = () => {
const router = useRouter();
@@ -77,27 +83,6 @@ export const useDropdown = () => {
});
if (type === "table") {
const { db, schema, table } = target as NodeTarget<"table">;
- items.push({
- key: "copy-url",
- label: t("sql-editor.copy-url"),
- icon: () => <LinkIcon class="w-4 h-4" />,
- onSelect: () => {
- const route = router.resolve({
- name: SQL_EDITOR_DATABASE_MODULE,
- params: {
- project: extractProjectResourceName(db.project),
- instance: extractInstanceResourceName(db.instance),
- database: db.databaseName,
- },
- query: {
- table: table.name,
- schema: schema.name,
- },
- });
- const url = new URL(route.href, window.location.origin).href;
- copyToClipboard(url);
- },
- });
items.push({
key: "copy-all-column-names",
@@ -109,18 +94,83 @@ export const useDropdown = () => {
},
});
- items.push({
- key: "view-schema-text",
- label: t("sql-editor.view-schema-text"),
- icon: () => <CodeIcon class="w-4 h-4" />,
- onSelect: () => {
- schemaViewer.value = {
- database: db,
- schema: schema.name,
- table: table.name,
- };
- },
- });
+ if (
+ VIEW_SCHEMA_ACTION_ENABLED_ENGINES.includes(db.instanceEntity.engine)
+ ) {
+ items.push({
+ key: "view-schema-text",
+ label: t("sql-editor.view-schema-text"),
+ icon: () => <CodeIcon class="w-4 h-4" />,
+ onSelect: () => {
+ schemaViewer.value = {
+ database: db,
+ schema: schema.name,
+ table: table.name,
+ };
+ },
+ });
+ }
+
+ if (pageMode.value === "BUNDLED") {
+ items.push({
+ key: "view-table-detail",
+ label: t("sql-editor.view-table-detail"),
+ icon: () => <ExternalLinkIcon class="w-4 h-4" />,
+ onSelect: () => {
+ const route = router.resolve({
+ name: PROJECT_V1_ROUTE_DATABASE_DETAIL,
+ params: {
+ projectId: extractProjectResourceName(db.project),
+ instanceId: extractInstanceResourceName(db.instance),
+ databaseName: db.databaseName,
+ },
+ query: {
+ schema: schema.name ? schema.name : undefined,
+ table: table.name,
+ },
+ });
+ const url = route.href;
+ window.open(url, "_blank");
+ },
+ });
+
+ if (instanceV1HasAlterSchema(db.instanceEntity)) {
+ items.push({
+ key: "edit-schema",
+ label: t("database.edit-schema"),
+ icon: () => <SquarePenIcon class="w-4 h-4" />,
+ onSelect: () => {
+ editorEvents.emit("alter-schema", {
+ databaseUID: db.uid,
+ schema: schema.name,
+ table: table.name,
+ });
+ },
+ });
+ }
+
+ items.push({
+ key: "copy-url",
+ label: t("sql-editor.copy-url"),
+ icon: () => <LinkIcon class="w-4 h-4" />,
+ onSelect: () => {
+ const route = router.resolve({
+ name: SQL_EDITOR_DATABASE_MODULE,
+ params: {
+ project: extractProjectResourceName(db.project),
+ instance: extractInstanceResourceName(db.instance),
+ database: db.databaseName,
+ },
+ query: {
+ table: table.name,
+ schema: schema.name,
+ },
+ });
+ const url = new URL(route.href, window.location.origin).href;
+ copyToClipboard(url);
+ },
+ });
+ }
}
if (targetSupportsSelectAll(target)) {
items.push({
@@ -157,45 +207,6 @@ export const useDropdown = () => {
},
});
}
- if (type === "table" && pageMode.value === "BUNDLED") {
- const { db, schema, table } = target as NodeTarget<"table">;
- items.push({
- key: "view-table-detail",
- label: t("sql-editor.view-table-detail"),
- icon: () => <ExternalLinkIcon class="w-4 h-4" />,
- onSelect: () => {
- const route = router.resolve({
- name: PROJECT_V1_ROUTE_DATABASE_DETAIL,
- params: {
- projectId: extractProjectResourceName(db.project),
- instanceId: extractInstanceResourceName(db.instance),
- databaseName: db.databaseName,
- },
- query: {
- schema: schema.name ? schema.name : undefined,
- table: table.name,
- },
- });
- const url = route.href;
- window.open(url, "_blank");
- },
- });
-
- if (instanceV1HasAlterSchema(db.instanceEntity)) {
- items.push({
- key: "edit-schema",
- label: t("database.edit-schema"),
- icon: () => <SquarePenIcon class="w-4 h-4" />,
- onSelect: () => {
- editorEvents.emit("alter-schema", {
- databaseUID: db.uid,
- schema: schema.name,
- table: table.name,
- });
- },
- });
- }
- }
}
const ORDERS = [
"copy-name",