Skip to content

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

feat: support using project wildcard to list database groups (#6356)

h3n4la793cabf8bc2
diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.go
index b2bb1c51a6..850d012c0a 100644
--- a/backend/api/v1/project_service.go
+++ b/backend/api/v1/project_service.go
@@ -782,6 +782,33 @@ func (s *ProjectService) ListDatabaseGroups(ctx context.Context, request *v1pb.L
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, err.Error())
}
+
+ if projectResourceID == "-" {
+ var apiDatabaseGroups []*v1pb.DatabaseGroup
+ databaseGroups, err := s.store.ListDatabaseGroups(ctx, &store.FindDatabaseGroupMessage{})
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ for _, databaseGroup := range databaseGroups {
+ project, err := s.store.GetProjectV2(ctx, &store.FindProjectMessage{
+ UID: &databaseGroup.ProjectUID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if project == nil {
+ return nil, status.Errorf(codes.DataLoss, "project %d not found", databaseGroup.ProjectUID)
+ }
+ if project.Deleted {
+ continue
+ }
+ apiDatabaseGroups = append(apiDatabaseGroups, convertStoreToAPIDatabaseGroupBasic(databaseGroup, project.ResourceID))
+ }
+ return &v1pb.ListDatabaseGroupsResponse{
+ DatabaseGroups: apiDatabaseGroups,
+ }, nil
+ }
+
project, err := s.store.GetProjectV2(ctx, &store.FindProjectMessage{
ResourceID: &projectResourceID,
})
diff --git a/backend/store/database_group.go b/backend/store/database_group.go
index 136474ea1b..60458126bb 100644
--- a/backend/store/database_group.go
+++ b/backend/store/database_group.go
@@ -107,7 +107,7 @@ func (s *Store) GetDatabaseGroup(ctx context.Context, find *FindDatabaseGroupMes
}
func (*Store) listDatabaseGroupImpl(ctx context.Context, tx *Tx, find *FindDatabaseGroupMessage) ([]*DatabaseGroupMessage, error) {
- where, args := []string{}, []any{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.ProjectUID; v != nil {
where, args = append(where, fmt.Sprintf("project_id = $%d", len(args)+1)), append(args, *v)
}
@@ -373,7 +373,7 @@ func (s *Store) GetSchemaGroup(ctx context.Context, find *FindSchemaGroupMessage
}
func (*Store) listSchemaGroupsImpl(ctx context.Context, tx *Tx, find *FindSchemaGroupMessage) ([]*SchemaGroupMessage, error) {
- where, args := []string{}, []any{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.DatabaseGroupUID; v != nil {
where, args = append(where, fmt.Sprintf("db_group_id = $%d", len(args)+1)), append(args, *v)
}
diff --git a/frontend/src/types/proto/v1/project_service.ts b/frontend/src/types/proto/v1/project_service.ts
index 3b4d58b6b4..591628166b 100644
--- a/frontend/src/types/proto/v1/project_service.ts
+++ b/frontend/src/types/proto/v1/project_service.ts
@@ -921,6 +921,7 @@ export interface ListDatabaseGroupsRequest {
/**
* The parent resource whose database groups are to be listed.
* Format: projects/{project}
+ * Using "projects/-" will list database groups across all projects.
*/
parent: string;
/**
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 209f82afee..2a4636158c 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -4560,7 +4560,7 @@ This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/. |
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| parent | [string](#string) | | The parent resource whose database groups are to be listed. Format: projects/{project} |
+| parent | [string](#string) | | The parent resource whose database groups are to be listed. Format: projects/{project} Using "projects/-" will list database groups across all projects. |
| page_size | [int32](#int32) | | Not used. The maximum number of anomalies to return. The service may return fewer than this value. If unspecified, at most 50 anomalies will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. |
| page_token | [string](#string) | | Not used. A page token, received from a previous `ListDatabaseGroups` call. Provide this to retrieve the subsequent page.
diff --git a/proto/generated-go/v1/project_service.pb.go b/proto/generated-go/v1/project_service.pb.go
index d852c4dd20..d787ac856e 100644
--- a/proto/generated-go/v1/project_service.pb.go
+++ b/proto/generated-go/v1/project_service.pb.go
@@ -2569,6 +2569,7 @@ type ListDatabaseGroupsRequest struct {
// The parent resource whose database groups are to be listed.
// Format: projects/{project}
+ // Using "projects/-" will list database groups across all projects.
Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"`
// Not used. The maximum number of anomalies to return. The service may return fewer than
// this value.
diff --git a/proto/v1/project_service.proto b/proto/v1/project_service.proto
index 27bd1ac79e..c101979408 100644
--- a/proto/v1/project_service.proto
+++ b/proto/v1/project_service.proto
@@ -604,6 +604,7 @@ message Activity {
message ListDatabaseGroupsRequest {
// The parent resource whose database groups are to be listed.
// Format: projects/{project}
+ // Using "projects/-" will list database groups across all projects.
string parent = 1 [(google.api.field_behavior) = REQUIRED];
// Not used. The maximum number of anomalies to return. The service may return fewer than