Skip to content

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

Writes back the latest schema file to the same branch as the push event.

天舟cdd920f6669d
diff --git a/server/task_executor_schema_update.go b/server/task_executor_schema_update.go
index 37e6e7273e..6fd645b7db 100644
--- a/server/task_executor_schema_update.go
+++ b/server/task_executor_schema_update.go
@@ -158,7 +158,10 @@ func (exec *SchemaUpdateTaskExecutor) RunOnce(ctx context.Context, server *Serve
bytebaseURL = fmt.Sprintf("%s:%d/issue/%s?stage=%d", server.frontendHost, server.frontendPort, api.IssueSlug(issue), task.StageId)
}
- branch := "master"
+ // Writes back the latest schema file to the same branch as the push event.
+ // Ref format refs/heads/<<branch>>
+ refComponents := strings.Split(payload.VCSPushEvent.Ref, "/")
+ branch := refComponents[len(refComponents)-1]
latestSchemaFile := fmt.Sprintf("%s__#LATEST.sql", databaseName)
filePath := fmt.Sprintf("projects/%s/repository/files/%s", repository.ExternalId, url.QueryEscape(latestSchemaFile))
getFilePath := filePath + "?ref=" + url.QueryEscape(branch)