Skip to content

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

feat(mongodb): forbid user run non-data migration for MongoDB database (#4096)

h3n4le3793e211dcb
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
index 10c6332654..8f10ce36ce 100644
--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
@@ -276,6 +276,8 @@ const databaseList = computed(() => {
}
list = list.filter((db) => db.syncStatus === "OK");
+ // We disallow users to alter schema for MongoDB databases.
+ list = list.filter((db) => db.instance.engine !== "MONGODB");
const keyword = state.searchText.trim();
list = list.filter((db) =>
diff --git a/server/issue.go b/server/issue.go
index cf3dc5f6b8..3974327719 100644
--- a/server/issue.go
+++ b/server/issue.go
@@ -845,6 +845,10 @@ func (s *Server) getPipelineCreateForDatabaseSchemaAndDataUpdate(ctx context.Con
if !ok {
return nil, echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database ID %d not found in project %d", d.DatabaseID, issueCreate.ProjectID))
}
+ if database.Instance.Engine == db.MongoDB && d.MigrationType != db.Data && d.MigrationType != db.Baseline {
+ // We disallow user to create non-data migration for MongoDB.
+ return nil, echo.NewHTTPError(http.StatusBadRequest, "Cannot create non-data migration for MongoDB, consider using data migration(DML) instead.")
+ }
matrix, err := utils.GetDatabaseMatrixFromDeploymentSchedule(deploySchedule, []*api.Database{database})
if err != nil {
return nil, echo.NewHTTPError(http.StatusInternalServerError, "Failed to build deployment pipeline").SetInternal(err)