Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: initial create context from tasks for grouping issue (#6526)
boojack0ada8fe6b8d6
diff --git a/frontend/src/components/Issue/logic/TenantModeProvider.ts b/frontend/src/components/Issue/logic/TenantModeProvider.tsindex 1daacfdef8..d55a01347b 100644--- a/frontend/src/components/Issue/logic/TenantModeProvider.ts+++ b/frontend/src/components/Issue/logic/TenantModeProvider.ts@@ -32,17 +32,23 @@ import {Sheet_Source,Sheet_Type,} from "@/types/proto/v1/sheet_service";+import { useRoute } from "vue-router";export default defineComponent({name: "TenantModeProvider",setup() {const { create, issue, selectedTask, createIssue, onStatusChanged } =useIssueLogic();+ const route = useRoute();const databaseStore = useDatabaseV1Store();const sheetV1Store = useSheetV1Store();const projectV1Store = useProjectV1Store();const taskStore = useTaskStore();+ const isGroupingIssue = computed(() => {+ return route.query.databaseGroupName !== "";+ });+const allowEditStatement = computed(() => {if (create.value) {return true;@@ -54,6 +60,10 @@ export default defineComponent({// In tenant mode, the entire issue shares only one SQL statementconst selectedStatement = computed(() => {if (create.value) {+ if (isGroupingIssue.value) {+ return selectedTask.value.statement;+ }+const issueCreate = issue.value as IssueCreate;const context = issueCreate.createContext as MigrationContext;return context.detailList[0].statement;@@ -72,6 +82,11 @@ export default defineComponent({const updateStatement = async (newStatement: string) => {if (create.value) {+ // For grouping issue, we don't allow to modify statement.+ if (isGroupingIssue.value) {+ return;+ }+// For tenant deploy mode, we apply the statement to all stages and all tasksconst allTaskList = flattenTaskList<TaskCreate>(issue.value);allTaskList.forEach((task) => {@@ -151,6 +166,24 @@ export default defineComponent({// throw errorreturn;}+ // For those database group issues, we create issue directly instead of creating sheets.+ if (route.query.databaseGroupName) {+ const taskList = flattenTaskList(issueCreate);+ context.detailList = [];+ for (const task of taskList) {+ context.detailList.push({+ migrationType: detail.migrationType,+ earliestAllowedTs: detail.earliestAllowedTs,+ databaseGroupName: route.query.databaseGroupName as string,+ databaseId: (task as any).databaseId,+ statement: (task as any).statement,+ sheetId: (task as any).sheetId,+ });+ }+ createIssue(issueCreate);+ return;+ }+const db = databaseStore.getDatabaseByUID(String(detail.databaseId!));if (!detail.sheetId || detail.sheetId === UNKNOWN_ID) {const statement = maybeFormatStatementOnSave(detail.statement, db);diff --git a/frontend/src/plugins/issue/logic/initialize/helper.ts b/frontend/src/plugins/issue/logic/initialize/helper.tsindex ad8273aa39..64c32eeee7 100644--- a/frontend/src/plugins/issue/logic/initialize/helper.ts+++ b/frontend/src/plugins/issue/logic/initialize/helper.ts@@ -149,6 +149,9 @@ const defaultStatementOfTask = (task: Task) => {if (task.type === "bb.task.database.schema.baseline") {return ESTABLISH_BASELINE_SQL;}+ if (task.statement) {+ return task.statement;+ }// if we are using VALIDATE_ONLY_SQL, set it back to empty// otherwise keep it as-isdiff --git a/frontend/src/plugins/issue/logic/initialize/tenant.ts b/frontend/src/plugins/issue/logic/initialize/tenant.tsindex 81efd67333..73f67def34 100644--- a/frontend/src/plugins/issue/logic/initialize/tenant.ts+++ b/frontend/src/plugins/issue/logic/initialize/tenant.ts@@ -51,15 +51,16 @@ const buildNewTenantSchemaUpdateIssue = async (migrationType = "DATA";}- const databaseList = findDatabaseListByQuery(context);const databaseGroupName = findDatabaseGroupNameByQuery(context);+ const databaseList = findDatabaseListByQuery(context);if (databaseGroupName) {+ const sql = route.query.sql as string;helper.issueCreate!.createContext = {detailList: [{migrationType: migrationType,databaseGroupName: databaseGroupName,- statement: VALIDATE_ONLY_SQL,+ statement: sql || VALIDATE_ONLY_SQL,earliestAllowedTs: 0,},],diff --git a/frontend/src/types/issue.ts b/frontend/src/types/issue.tsindex 3d0111a63b..e9c9d60ec3 100644--- a/frontend/src/types/issue.ts+++ b/frontend/src/types/issue.ts@@ -58,6 +58,7 @@ export type MigrationDetail = {sheetId: SheetId;earliestAllowedTs: number;databaseId?: DatabaseId;+ databaseGroupName?: string;rollbackEnabled?: boolean;rollbackDetail?: RollbackDetail;};diff --git a/frontend/src/types/pipeline/task.ts b/frontend/src/types/pipeline/task.tsindex 8bafbc5645..d06be27876 100644--- a/frontend/src/types/pipeline/task.ts+++ b/frontend/src/types/pipeline/task.ts@@ -185,6 +185,8 @@ export type Task = {// Tasks such as creating database may not have database.database?: Database;payload?: TaskPayload;+ // Using by grouping batch change.+ statement?: string;// Task DAGblockedBy: Task[];