Skip to content

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

fix: missing push event when establish baseline (#2659)

boojack417c0366dff9
diff --git a/frontend/src/components/Issue/logic/common.ts b/frontend/src/components/Issue/logic/common.ts
index aeb77264a2..f14e9af418 100644
--- a/frontend/src/components/Issue/logic/common.ts
+++ b/frontend/src/components/Issue/logic/common.ts
@@ -4,6 +4,7 @@ import formatSQL from "@/components/MonacoEditor/sqlFormatter";
import {
useCurrentUser,
useDatabaseStore,
+ useInstanceStore,
useIssueStore,
useTaskStore,
useUIStateStore,
@@ -24,6 +25,7 @@ import {
TaskId,
TaskPatch,
TaskType,
+ UpdateSchemaContext,
UpdateSchemaDetail,
} from "@/types";
import { useIssueLogic } from "./index";
@@ -189,11 +191,31 @@ export const useCommonLogic = () => {
earliestAllowedTs: task.earliestAllowedTs,
};
});
+ const migrationType = taskList[0].migrationType!;
+
issueCreate.createContext = {
- migrationType: taskList[0].migrationType!,
+ migrationType,
updateSchemaDetailList: detailList,
};
+ // If the database is within VCS project, try to find its latest and done migration history from VCS.
+ // If not found, keep the vcsPushEvent field empty and check in backend.
+ if (migrationType === "BASELINE" && detailList.length === 1) {
+ const databaseId = detailList[0].databaseId;
+ const database = databaseStore.getDatabaseById(databaseId);
+ if (database.project.workflowType === "VCS") {
+ const migrationHistory =
+ useInstanceStore().getLatestDoneVCSMigrationHistory(
+ database.instance.id,
+ database.name
+ );
+ if (migrationHistory) {
+ (issueCreate.createContext as UpdateSchemaContext).vcsPushEvent =
+ migrationHistory.payload?.pushEvent;
+ }
+ }
+ }
+
createIssue(issueCreate);
};
diff --git a/frontend/src/plugins/issue/logic/initialize/helper.ts b/frontend/src/plugins/issue/logic/initialize/helper.ts
index ab242d0f81..2eaaed465a 100644
--- a/frontend/src/plugins/issue/logic/initialize/helper.ts
+++ b/frontend/src/plugins/issue/logic/initialize/helper.ts
@@ -8,12 +8,7 @@ import {
TaskDatabaseSchemaUpdatePayload,
UNKNOWN_ID,
} from "@/types";
-import {
- useActuatorStore,
- useCurrentUser,
- useIssueStore,
- useInstanceStore,
-} from "@/store";
+import { useActuatorStore, useCurrentUser, useIssueStore } from "@/store";
import { BuildNewIssueContext, VALIDATE_ONLY_SQL } from "../common";
export class IssueCreateHelper {
@@ -21,7 +16,6 @@ export class IssueCreateHelper {
issue: Issue | null;
context: BuildNewIssueContext;
issueStore: ReturnType<typeof useIssueStore>;
- intanceStore: ReturnType<typeof useInstanceStore>;
currentUser: Ref<Principal>;
constructor(context: BuildNewIssueContext) {
@@ -29,7 +23,6 @@ export class IssueCreateHelper {
this.issue = null;
this.context = context;
this.issueStore = useIssueStore();
- this.intanceStore = useInstanceStore();
this.currentUser = useCurrentUser();
}
diff --git a/frontend/src/plugins/issue/logic/initialize/standard.ts b/frontend/src/plugins/issue/logic/initialize/standard.ts
index 783c303d58..5d564ce65e 100644
--- a/frontend/src/plugins/issue/logic/initialize/standard.ts
+++ b/frontend/src/plugins/issue/logic/initialize/standard.ts
@@ -1,4 +1,5 @@
import { TemplateType } from "@/plugins";
+import { useInstanceStore } from "@/store";
import {
IssueCreate,
IssueCreateContext,
@@ -47,11 +48,12 @@ export const buildNewStandardIssue = async (
// If the database is within VCS project, try to find its latest and done migration history from VCS.
// If not found, keep the vcsPushEvent field empty and check in backend.
+ // (Validate only)
if (migrationType === "BASELINE" && databaseList.length === 1) {
const database = databaseList[0];
if (database.project.workflowType === "VCS") {
const migrationHistory =
- helper.intanceStore.getLatestDoneVCSMigrationHistory(
+ useInstanceStore().getLatestDoneVCSMigrationHistory(
database.instance.id,
database.name
);