Skip to content

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

fix: reconcile plan for db group (#12709)

boojackcb98b3d7b6dc
diff --git a/backend/runner/taskrun/database_create_executor.go b/backend/runner/taskrun/database_create_executor.go
index e147853fa0..45fbd321bb 100644
--- a/backend/runner/taskrun/database_create_executor.go
+++ b/backend/runner/taskrun/database_create_executor.go
@@ -288,8 +288,23 @@ func (exec *DatabaseCreateExecutor) reconcilePlan(ctx context.Context, project *
if c == nil {
return nil
}
- if _, _, err := common.GetProjectIDDeploymentConfigID(c.Target); err != nil {
- // continue because this is not a plan that uses deployment config.
+ _, databaseGroupID, err := common.GetProjectIDDatabaseGroupID(c.Target)
+ if err != nil {
+ // continue because this is not a plan that uses database group.
+ //nolint:nilerr
+ return nil
+ }
+ databaseGroup, err := exec.store.GetDatabaseGroup(ctx, &store.FindDatabaseGroupMessage{ResourceID: &databaseGroupID})
+ if err != nil {
+ //nolint:nilerr
+ return nil
+ }
+ if databaseGroup == nil || !databaseGroup.Payload.Multitenancy {
+ return nil
+ }
+ isMatched, err := utils.CheckDatabaseGroupMatch(ctx, databaseGroup, createdDatabase)
+ if err != nil || !isMatched {
+ // continue if current database is not matched.
//nolint:nilerr
return nil
}