Skip to content

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

chore: use check release in sql check button (#15233)

boojack1428e0f49564
diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue
index 1e3331fb3b..0e74f4fcde 100644
--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorSQLCheckButton/SchemaEditorSQLCheckButton.vue
@@ -5,8 +5,8 @@
:get-statement="getStatement"
:change-type="
useOnlineSchemaMigration
- ? CheckRequest_ChangeType.DDL_GHOST
- : CheckRequest_ChangeType.DDL
+ ? Release_File_ChangeType.DDL_GHOST
+ : Release_File_ChangeType.DDL
"
:button-props="{
size: 'small',
@@ -28,7 +28,7 @@
import { toRef } from "vue";
import { SQLCheckButton } from "@/components/SQLCheck";
import type { ComposedDatabase } from "@/types";
-import { CheckRequest_ChangeType } from "@/types/proto/v1/sql_service";
+import { Release_File_ChangeType } from "@/types/proto/v1/release_service";
import type { Defer } from "@/utils";
import OnlineMigrationAdviceExtra from "./OnlineMigrationAdviceExtra.vue";
import { useSchemaEditorSQLCheck } from "./useSchemaEditorSQLCheck";
diff --git a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue
index a48a0f29d4..28a6393c64 100644
--- a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue
+++ b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue
@@ -48,8 +48,9 @@ import {
import { SQLCheckButton } from "@/components/SQLCheck";
import { TaskTypeListWithStatement } from "@/types";
import { Plan_ChangeDatabaseConfig_Type } from "@/types/proto/v1/plan_service";
+import { Release_File_ChangeType } from "@/types/proto/v1/release_service";
import { Task_Type } from "@/types/proto/v1/rollout_service";
-import { Advice, CheckRequest_ChangeType } from "@/types/proto/v1/sql_service";
+import { Advice } from "@/types/proto/v1/sql_service";
import type { Defer } from "@/utils/util";
import { useTaskSheet } from "../StatementSection/useTaskSheet";
import OnlineMigrationAdviceExtra from "./OnlineMigrationAdviceExtra.vue";
@@ -94,15 +95,15 @@ const handleToggleOnlineMigration = (
confirm?.resolve(false);
};
-const changeType = computed((): CheckRequest_ChangeType | undefined => {
+const changeType = computed((): Release_File_ChangeType | undefined => {
const spec = specForTask(issue.value.planEntity, selectedTask.value);
switch (spec?.changeDatabaseConfig?.type) {
case Plan_ChangeDatabaseConfig_Type.MIGRATE:
- return CheckRequest_ChangeType.DDL;
+ return Release_File_ChangeType.DDL;
case Plan_ChangeDatabaseConfig_Type.MIGRATE_GHOST:
- return CheckRequest_ChangeType.DDL_GHOST;
+ return Release_File_ChangeType.DDL_GHOST;
case Plan_ChangeDatabaseConfig_Type.DATA:
- return CheckRequest_ChangeType.DML;
+ return Release_File_ChangeType.DML;
}
return undefined;
});
diff --git a/frontend/src/components/Plan/components/SQLCheckSection/SQLCheckSection.vue b/frontend/src/components/Plan/components/SQLCheckSection/SQLCheckSection.vue
index 9aceb7a1ae..e99b8ca6d2 100644
--- a/frontend/src/components/Plan/components/SQLCheckSection/SQLCheckSection.vue
+++ b/frontend/src/components/Plan/components/SQLCheckSection/SQLCheckSection.vue
@@ -34,7 +34,8 @@ import { computed } from "vue";
import { databaseForSpec } from "@/components/Plan/logic";
import { SQLCheckButton } from "@/components/SQLCheck";
import { Plan_ChangeDatabaseConfig_Type } from "@/types/proto/v1/plan_service";
-import { Advice, CheckRequest_ChangeType } from "@/types/proto/v1/sql_service";
+import { Release_File_ChangeType } from "@/types/proto/v1/release_service";
+import { Advice } from "@/types/proto/v1/sql_service";
import { usePlanContext } from "../../logic";
import { useSpecSheet } from "../StatementSection/useSpecSheet";
import SQLCheckBadge from "./SQLCheckBadge.vue";
@@ -57,14 +58,14 @@ const getStatement = async () => {
};
};
-const changeType = computed((): CheckRequest_ChangeType | undefined => {
+const changeType = computed((): Release_File_ChangeType | undefined => {
switch (selectedSpec.value?.changeDatabaseConfig?.type) {
case Plan_ChangeDatabaseConfig_Type.MIGRATE:
- return CheckRequest_ChangeType.DDL;
+ return Release_File_ChangeType.DDL;
case Plan_ChangeDatabaseConfig_Type.MIGRATE_GHOST:
- return CheckRequest_ChangeType.DDL_GHOST;
+ return Release_File_ChangeType.DDL_GHOST;
case Plan_ChangeDatabaseConfig_Type.DATA:
- return CheckRequest_ChangeType.DML;
+ return Release_File_ChangeType.DML;
}
return undefined;
});
diff --git a/frontend/src/components/SQLCheck/SQLCheckButton.vue b/frontend/src/components/SQLCheck/SQLCheckButton.vue
index 4e04aecac3..e09d15ea8c 100644
--- a/frontend/src/components/SQLCheck/SQLCheckButton.vue
+++ b/frontend/src/components/SQLCheck/SQLCheckButton.vue
@@ -75,16 +75,20 @@
<script lang="ts" setup>
import type { ButtonProps } from "naive-ui";
import { NButton, NPopover } from "naive-ui";
+import { v4 as uuidv4 } from "uuid";
import { computed, onUnmounted, ref, watch } from "vue";
import { onMounted } from "vue";
import { useI18n } from "vue-i18n";
import { BBSpin } from "@/bbkit";
-import { sqlServiceClient } from "@/grpcweb";
+import { releaseServiceClient } from "@/grpcweb";
import { WORKSPACE_ROUTE_SQL_REVIEW } from "@/router/dashboard/workspaceRoutes";
import { useReviewPolicyForDatabase } from "@/store";
import type { ComposedDatabase } from "@/types";
import type { DatabaseMetadata } from "@/types/proto/v1/database_service";
-import type { CheckRequest_ChangeType } from "@/types/proto/v1/sql_service";
+import {
+ Release_File_ChangeType,
+ ReleaseFileType,
+} from "@/types/proto/v1/release_service";
import { Advice, Advice_Status } from "@/types/proto/v1/sql_service";
import type { Defer, VueStyle } from "@/utils";
import { defer, hasWorkspacePermissionV2 } from "@/utils";
@@ -104,7 +108,7 @@ const props = withDefaults(
databaseMetadata?: DatabaseMetadata;
buttonProps?: ButtonProps;
buttonStyle?: VueStyle;
- changeType?: CheckRequest_ChangeType;
+ changeType?: Release_File_ChangeType;
showCodeLocation?: boolean;
ignoreIssueCreationRestriction?: boolean;
adviceFilter?: (advices: Advice, index: number) => boolean;
@@ -174,16 +178,23 @@ const policyErrors = computed(() => {
providePlanCheckRunContext({});
-const runCheckInternal = async (
- statement: string,
- databaseMetadata: DatabaseMetadata | undefined
-) => {
+const runCheckInternal = async (statement: string) => {
const { database, changeType } = props;
- const result = await sqlServiceClient.check({
- statement,
- name: database.name,
- metadata: databaseMetadata,
- changeType,
+ const result = await releaseServiceClient.checkRelease({
+ parent: database.project,
+ release: {
+ files: [
+ {
+ // Use a random uuid to avoid duplication.
+ version: uuidv4(),
+ type: ReleaseFileType.VERSIONED,
+ statement: statement,
+ // Default to DDL change type.
+ changeType: changeType || Release_File_ChangeType.DDL,
+ },
+ ],
+ },
+ targets: [database.name],
});
return result;
};
@@ -229,8 +240,8 @@ const runChecks = async () => {
return handleErrors(errors);
}
try {
- const result = await runCheckInternal(statement, props.databaseMetadata);
- rawAdvices.value = result.advices;
+ const checkResult = await runCheckInternal(statement);
+ rawAdvices.value = checkResult.results.flatMap((r) => r.advices);
} finally {
isRunning.value = false;
}