Skip to content

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

chore: check update schema context for baseline issue (#2267)

boojack2150c7f61873
diff --git a/api/issue.go b/api/issue.go
index 83085e69f4..ec10fa8514 100644
--- a/api/issue.go
+++ b/api/issue.go
@@ -159,7 +159,7 @@ type UpdateSchemaContext struct {
// When a project is in tenant mode, there should be one item in the list.
DetailList []*UpdateSchemaDetail `json:"updateSchemaDetailList"`
// VCSPushEvent is the event information for VCS push.
- VCSPushEvent *vcs.PushEvent
+ VCSPushEvent *vcs.PushEvent `json:"vcsPushEvent"`
}
// UpdateSchemaGhostDetail is the detail of updating database schema using gh-ost.
diff --git a/server/issue.go b/server/issue.go
index 2c198f285f..7b8c542536 100644
--- a/server/issue.go
+++ b/server/issue.go
@@ -566,6 +566,15 @@ func (s *Server) getPipelineCreateForDatabaseSchemaAndDataUpdate(ctx context.Con
return nil, echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch project with ID %d", issueCreate.ProjectID)).SetInternal(err)
}
+ // If migration type is establishing baseline and project's workflow is VCS,
+ // then the context must contain a VCS push event field. We need this VCS
+ // context to identify the write-back destination after migration.
+ if c.MigrationType == db.Baseline && project.WorkflowType == api.VCSWorkflow {
+ if c.VCSPushEvent == nil {
+ return nil, echo.NewHTTPError(http.StatusBadRequest, "Failed to create establishing baseline issue for GitOps workflow project, vcs context missing")
+ }
+ }
+
schemaVersion := common.DefaultMigrationVersion()
// Tenant mode project pipeline has its own generation.
if project.TenantMode == api.TenantModeTenant {