Skip to content

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

feat(api): implement schema group crud (#6296)

h3n4l26970f2a4967
diff --git a/backend/api/v1/common.go b/backend/api/v1/common.go
index 99c6a6d12b..fd94800caa 100644
--- a/backend/api/v1/common.go
+++ b/backend/api/v1/common.go
@@ -45,6 +45,7 @@ const (
webhookIDPrefix = "webhooks/"
sheetIDPrefix = "sheets/"
databaseGroupNamePrefix = "databaseGroups/"
+ schemaGroupNamePrefix = "schemaGroups/"
changeHistoryPrefix = "changeHistories/"
deploymentConfigSuffix = "/deploymentConfig"
@@ -92,6 +93,14 @@ func getProjectIDDatabaseGroupID(name string) (string, string, error) {
return tokens[0], tokens[1], nil
}
+func getProjectIDDatabaseGroupIDSchemaGroupID(name string) (string, string, string, error) {
+ tokens, err := getNameParentTokens(name, databaseGroupNamePrefix, schemaGroupNamePrefix)
+ if err != nil {
+ return "", "", "", err
+ }
+ return tokens[0], tokens[1], tokens[2], nil
+}
+
func getProjectIDWebhookID(name string) (string, string, error) {
tokens, err := getNameParentTokens(name, projectNamePrefix, webhookIDPrefix)
if err != nil {
diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.go
index e9170b1358..c3c1902fd4 100644
--- a/backend/api/v1/project_service.go
+++ b/backend/api/v1/project_service.go
@@ -668,10 +668,13 @@ func (s *ProjectService) CreateDatabaseGroup(ctx context.Context, request *v1pb.
if request.DatabaseGroup.DatabasePlaceholder == "" {
return nil, status.Errorf(codes.InvalidArgument, "database group database placeholder is required")
}
+ if request.DatabaseGroup.DatabaseExpr == nil {
+ return nil, status.Errorf(codes.InvalidArgument, "database group database expression is required")
+ }
principalID := ctx.Value(common.PrincipalIDContextKey).(int)
storeDatabaseGroup := &store.DatabaseGroupMessage{
- CreatorID: principalID,
+ ResourceID: request.DatabaseGroupId,
ProjectResourceID: project.ResourceID,
Placeholder: request.DatabaseGroup.DatabasePlaceholder,
Expression: request.DatabaseGroup.DatabaseExpr,
@@ -833,6 +836,251 @@ func (s *ProjectService) GetDatabaseGroup(ctx context.Context, request *v1pb.Get
return convertStoreToAPIDatabaseGroup(databaseGroup), nil
}
+// CreateSchemaGroup creates a database group.
+func (s *ProjectService) CreateSchemaGroup(ctx context.Context, request *v1pb.CreateSchemaGroupRequest) (*v1pb.SchemaGroup, error) {
+ projectResourceID, databaseGroupResourceID, err := getProjectIDDatabaseGroupID(request.Parent)
+ if err != nil {
+ return nil, status.Errorf(codes.InvalidArgument, err.Error())
+ }
+ project, err := s.store.GetProjectV2(ctx, &store.FindProjectMessage{
+ ResourceID: &projectResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if project == nil {
+ return nil, status.Errorf(codes.NotFound, "project %q not found", request.Parent)
+ }
+ if project.Deleted {
+ return nil, status.Errorf(codes.InvalidArgument, "project %q has been deleted", request.Parent)
+ }
+ databaseGroup, err := s.store.GetDatabaseGroup(ctx, &store.FindDatabaseGroupMessage{
+ ResourceID: &databaseGroupResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if databaseGroup == nil {
+ return nil, status.Errorf(codes.NotFound, "database group %q not found", databaseGroupResourceID)
+ }
+
+ // The id value should be 4-63 characters, and valid characters are /[a-z][0-9]-/.
+ if len(request.SchemaGroupId) < 4 || len(request.SchemaGroupId) > 63 {
+ return nil, status.Errorf(codes.InvalidArgument, "schema group id %q must be between 4 and 63 characters", request.SchemaGroupId)
+ }
+ for _, c := range request.SchemaGroupId {
+ if !((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '-') {
+ return nil, status.Errorf(codes.InvalidArgument, "invalid schema group id %q", request.SchemaGroupId)
+ }
+ }
+ if request.SchemaGroup.TablePlaceholder == "" {
+ return nil, status.Errorf(codes.InvalidArgument, "schema group table placeholder is required")
+ }
+ if request.SchemaGroup.TableExpr == nil {
+ return nil, status.Errorf(codes.InvalidArgument, "schema group table expression is required")
+ }
+
+ principalID := ctx.Value(common.PrincipalIDContextKey).(int)
+ storeSchemaGroup := &store.SchemaGroupMessage{
+ ResourceID: request.SchemaGroupId,
+ DatabaseGroupResourceID: databaseGroup.ResourceID,
+ Placeholder: request.SchemaGroup.TablePlaceholder,
+ Expression: request.SchemaGroup.TableExpr,
+ }
+ schemaGroup, err := s.store.CreateSchemaGroup(ctx, principalID, storeSchemaGroup)
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ return convertStoreToAPISchemaGroup(schemaGroup, projectResourceID), nil
+}
+
+// UpdateSchemaGroup updates a schema group.
+func (s *ProjectService) UpdateSchemaGroup(ctx context.Context, request *v1pb.UpdateSchemaGroupRequest) (*v1pb.SchemaGroup, error) {
+ projectResourceID, databaseGroupResourceID, schemaGroupResourceID, err := getProjectIDDatabaseGroupIDSchemaGroupID(request.SchemaGroup.Name)
+ if err != nil {
+ return nil, status.Errorf(codes.InvalidArgument, err.Error())
+ }
+ project, err := s.store.GetProjectV2(ctx, &store.FindProjectMessage{
+ ResourceID: &projectResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if project == nil {
+ return nil, status.Errorf(codes.NotFound, "project %q not found", projectResourceID)
+ }
+ if project.Deleted {
+ return nil, status.Errorf(codes.InvalidArgument, "project %q has been deleted", projectResourceID)
+ }
+ databaseGroup, err := s.store.GetDatabaseGroup(ctx, &store.FindDatabaseGroupMessage{
+ ResourceID: &databaseGroupResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if databaseGroup == nil {
+ return nil, status.Errorf(codes.NotFound, "database group %q not found", databaseGroupResourceID)
+ }
+ existedSchemaGroup, err := s.store.GetSchemaGroup(ctx, &store.FindSchemaGroupMessage{
+ ResourceID: &schemaGroupResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if existedSchemaGroup == nil {
+ return nil, status.Errorf(codes.NotFound, "schema group %q not found", schemaGroupResourceID)
+ }
+
+ var updateSchemaGroup store.UpdateSchemaGroupMessage
+ for _, path := range request.UpdateMask.Paths {
+ switch path {
+ case "table_placeholder":
+ if request.SchemaGroup.TablePlaceholder == "" {
+ return nil, status.Errorf(codes.InvalidArgument, "schema group table placeholder is required")
+ }
+ updateSchemaGroup.Placeholder = &request.SchemaGroup.TablePlaceholder
+ case "table_expr":
+ if request.SchemaGroup.TableExpr == nil {
+ return nil, status.Errorf(codes.InvalidArgument, "schema group table expr is required")
+ }
+ default:
+ return nil, status.Errorf(codes.InvalidArgument, "unsupported path: %q", path)
+ }
+ }
+ principalID := ctx.Value(common.PrincipalIDContextKey).(int)
+ schemaGroup, err := s.store.UpdateSchemaGroup(ctx, principalID, schemaGroupResourceID, &updateSchemaGroup)
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ return convertStoreToAPISchemaGroup(schemaGroup, projectResourceID), nil
+}
+
+// DeleteSchemaGroup deletes a schema group.
+func (s *ProjectService) DeleteSchemaGroup(ctx context.Context, request *v1pb.DeleteSchemaGroupRequest) (*emptypb.Empty, error) {
+ projectResourceID, databaseGroupResourceID, schemaGroupResourceID, err := getProjectIDDatabaseGroupIDSchemaGroupID(request.Name)
+ if err != nil {
+ return nil, status.Errorf(codes.InvalidArgument, err.Error())
+ }
+ project, err := s.store.GetProjectV2(ctx, &store.FindProjectMessage{
+ ResourceID: &projectResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if project == nil {
+ return nil, status.Errorf(codes.NotFound, "project %q not found", projectResourceID)
+ }
+ if project.Deleted {
+ return nil, status.Errorf(codes.InvalidArgument, "project %q has been deleted", projectResourceID)
+ }
+ databaseGroup, err := s.store.GetDatabaseGroup(ctx, &store.FindDatabaseGroupMessage{
+ ResourceID: &databaseGroupResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if databaseGroup == nil {
+ return nil, status.Errorf(codes.NotFound, "database group %q not found", databaseGroupResourceID)
+ }
+ existedSchemaGroup, err := s.store.GetSchemaGroup(ctx, &store.FindSchemaGroupMessage{
+ ResourceID: &schemaGroupResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if existedSchemaGroup == nil {
+ return nil, status.Errorf(codes.NotFound, "schema group %q not found", schemaGroupResourceID)
+ }
+
+ err = s.store.DeleteSchemaGroup(ctx, schemaGroupResourceID)
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ return &emptypb.Empty{}, nil
+}
+
+// ListSchemaGroups lists database groups.
+func (s *ProjectService) ListSchemaGroups(ctx context.Context, request *v1pb.ListSchemaGroupsRequest) (*v1pb.ListSchemaGroupsResponse, error) {
+ projectResourceID, databaseResourceID, err := getProjectIDDatabaseGroupID(request.Parent)
+ if err != nil {
+ return nil, status.Errorf(codes.InvalidArgument, err.Error())
+ }
+ project, err := s.store.GetProjectV2(ctx, &store.FindProjectMessage{
+ ResourceID: &projectResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if project == nil {
+ return nil, status.Errorf(codes.NotFound, "project %q not found", projectResourceID)
+ }
+ if project.Deleted {
+ return nil, status.Errorf(codes.InvalidArgument, "project %q has been deleted", projectResourceID)
+ }
+ databaseGroup, err := s.store.GetDatabaseGroup(ctx, &store.FindDatabaseGroupMessage{
+ ResourceID: &databaseResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if databaseGroup == nil {
+ return nil, status.Errorf(codes.NotFound, "database group %q not found", databaseResourceID)
+ }
+
+ schemaGroups, err := s.store.ListSchemaGroups(ctx, &store.FindSchemaGroupMessage{
+ DatabaseGroupResourceID: &databaseResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ var apiSchemaGroups []*v1pb.SchemaGroup
+ for _, schemaGroup := range schemaGroups {
+ apiSchemaGroups = append(apiSchemaGroups, convertStoreToAPISchemaGroup(schemaGroup, projectResourceID))
+ }
+ return &v1pb.ListSchemaGroupsResponse{
+ SchemaGroups: apiSchemaGroups,
+ }, nil
+}
+
+// GetSchemaGroup gets a database group.
+func (s *ProjectService) GetSchemaGroup(ctx context.Context, request *v1pb.GetSchemaGroupRequest) (*v1pb.SchemaGroup, error) {
+ projectResourceID, databaseGroupResourceID, schemaGroupResourceID, err := getProjectIDDatabaseGroupIDSchemaGroupID(request.Name)
+ if err != nil {
+ return nil, status.Errorf(codes.InvalidArgument, err.Error())
+ }
+ project, err := s.store.GetProjectV2(ctx, &store.FindProjectMessage{
+ ResourceID: &projectResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if project == nil {
+ return nil, status.Errorf(codes.NotFound, "project %q not found", projectResourceID)
+ }
+ if project.Deleted {
+ return nil, status.Errorf(codes.InvalidArgument, "project %q has been deleted", projectResourceID)
+ }
+ databaseGroup, err := s.store.GetDatabaseGroup(ctx, &store.FindDatabaseGroupMessage{
+ ResourceID: &databaseGroupResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if databaseGroup == nil {
+ return nil, status.Errorf(codes.NotFound, "database group %q not found", databaseGroupResourceID)
+ }
+ schemaGroup, err := s.store.GetSchemaGroup(ctx, &store.FindSchemaGroupMessage{
+ ResourceID: &schemaGroupResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if schemaGroup == nil {
+ return nil, status.Errorf(codes.NotFound, "schema group %q not found", schemaGroupResourceID)
+ }
+ return convertStoreToAPISchemaGroup(schemaGroup, schemaGroupResourceID), nil
+}
+
func convertStoreToAPIDatabaseGroup(databaseGroup *store.DatabaseGroupMessage) *v1pb.DatabaseGroup {
return &v1pb.DatabaseGroup{
Name: fmt.Sprintf("%s%s/%s%s", projectNamePrefix, databaseGroup.ProjectResourceID, databaseGroupNamePrefix, databaseGroup.ResourceID),
@@ -841,6 +1089,14 @@ func convertStoreToAPIDatabaseGroup(databaseGroup *store.DatabaseGroupMessage) *
}
}
+func convertStoreToAPISchemaGroup(schemaGroup *store.SchemaGroupMessage, projectResourceID string) *v1pb.SchemaGroup {
+ return &v1pb.SchemaGroup{
+ Name: fmt.Sprintf("%s%s/%s%s/%s%s", projectNamePrefix, projectResourceID, databaseGroupNamePrefix, schemaGroup.DatabaseGroupResourceID, schemaGroupNamePrefix, schemaGroup.ResourceID),
+ TablePlaceholder: schemaGroup.Placeholder,
+ TableExpr: schemaGroup.Expression,
+ }
+}
+
func convertToStoreProjectWebhookMessage(webhook *v1pb.Webhook) (*store.ProjectWebhookMessage, error) {
tp, err := convertToAPIWebhookTypeString(webhook.Type)
if err != nil {
diff --git a/backend/store/database_group.go b/backend/store/database_group.go
index e7b85b4e5b..560148c345 100644
--- a/backend/store/database_group.go
+++ b/backend/store/database_group.go
@@ -177,7 +177,7 @@ func (s *Store) UpdateDatabaseGroup(ctx context.Context, updaterPrincipalID int,
if err != nil {
return nil, errors.Wrapf(err, "failed to marshal expression")
}
- set, args = append(set, fmt.Sprintf("placeholder = $%d", len(args)+1)), append(args, jsonExpr)
+ set, args = append(set, fmt.Sprintf("expression = $%d", len(args)+1)), append(args, jsonExpr)
}
args = append(args, databaseGroupResourceID)
query := fmt.Sprintf(`
diff --git a/backend/store/schema_group.go b/backend/store/schema_group.go
new file mode 100644
index 0000000000..778b5d56a3
--- /dev/null
+++ b/backend/store/schema_group.go
@@ -0,0 +1,280 @@
+package store
+
+import (
+ "context"
+ "database/sql"
+ "fmt"
+ "strings"
+
+ "github.com/pkg/errors"
+ "google.golang.org/genproto/googleapis/type/expr"
+ "google.golang.org/protobuf/encoding/protojson"
+)
+
+// SchemaGroupMessage is the message for schema groups.
+type SchemaGroupMessage struct {
+ // Output only fields.
+ //
+ ID int64
+ CreatedTs int64
+ UpdatedTs int64
+ CreatorID int
+ UpdaterID int
+
+ // Normal fields.
+ //
+ DatabaseGroupResourceID string
+ ResourceID string
+ Placeholder string
+ Expression *expr.Expr
+}
+
+// FindSchemaGroupMessage is the message for finding schema group.
+type FindSchemaGroupMessage struct {
+ DatabaseGroupResourceID *string
+ ResourceID *string
+}
+
+// UpdateSchemaGroupMessage is the message for updating schema group.
+type UpdateSchemaGroupMessage struct {
+ Placeholder *string
+ Expression *expr.Expr
+}
+
+// DeleteSchemaGroup deletes a schema group.
+func (s *Store) DeleteSchemaGroup(ctx context.Context, resourceID string) error {
+ query := `
+ DELETE FROM schema_group WHERE resource_id = $1;
+ `
+ tx, err := s.db.BeginTx(ctx, nil)
+ if err != nil {
+ return errors.Wrapf(err, "failed to begin transaction")
+ }
+ defer tx.Rollback()
+ if _, err := tx.ExecContext(ctx, query, resourceID); err != nil {
+ return errors.Wrapf(err, "failed to exec")
+ }
+ if err := tx.Commit(); err != nil {
+ return errors.Wrapf(err, "failed to commit transaction")
+ }
+ return nil
+}
+
+// ListSchemaGroups lists schema groups.
+func (s *Store) ListSchemaGroups(ctx context.Context, find *FindSchemaGroupMessage) ([]*SchemaGroupMessage, error) {
+ tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})
+ if err != nil {
+ return nil, err
+ }
+ defer tx.Rollback()
+
+ schemaGroups, err := s.listSchemaGroupsImpl(ctx, tx, find)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to list schema groups")
+ }
+
+ if err := tx.Commit(); err != nil {
+ return nil, errors.Wrapf(err, "failed to commit transaction")
+ }
+
+ return schemaGroups, nil
+}
+
+// GetSchemaGroup gets a schema group.
+func (s *Store) GetSchemaGroup(ctx context.Context, find *FindSchemaGroupMessage) (*SchemaGroupMessage, error) {
+ tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})
+ if err != nil {
+ return nil, err
+ }
+ defer tx.Rollback()
+
+ schemaGroups, err := s.listSchemaGroupsImpl(ctx, tx, find)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to list schema groups")
+ }
+
+ if err := tx.Commit(); err != nil {
+ return nil, errors.Wrapf(err, "failed to commit transaction")
+ }
+
+ if len(schemaGroups) == 0 {
+ return nil, nil
+ }
+ if len(schemaGroups) > 1 {
+ return nil, errors.Errorf("found multiple schema groups")
+ }
+ return schemaGroups[0], nil
+}
+
+func (*Store) listSchemaGroupsImpl(ctx context.Context, tx *Tx, find *FindSchemaGroupMessage) ([]*SchemaGroupMessage, error) {
+ where, args := []string{}, []any{}
+ if v := find.DatabaseGroupResourceID; v != nil {
+ where, args = append(where, fmt.Sprintf("db_group_resource_id = $%d", len(args)+1)), append(args, *v)
+ }
+ if v := find.ResourceID; v != nil {
+ where, args = append(where, fmt.Sprintf("resource_id = $%d", len(args)+1)), append(args, *v)
+ }
+
+ query := fmt.Sprintf(`SELECT
+ id,
+ created_ts,
+ updated_ts,
+ creator_id,
+ updater_id,
+ db_group_resource_id,
+ resource_id,
+ placeholder,
+ expression
+ FROM schema_group %s ORDER BY id DESC;`, strings.Join(where, " AND "))
+
+ var schemaGroups []*SchemaGroupMessage
+
+ rows, err := tx.QueryContext(ctx, query, args...)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to scan")
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ var schemaGroup SchemaGroupMessage
+ var stringExpr string
+ if err := rows.Scan(
+ &schemaGroup.ID,
+ &schemaGroup.CreatedTs,
+ &schemaGroup.UpdatedTs,
+ &schemaGroup.CreatorID,
+ &schemaGroup.UpdaterID,
+ &schemaGroup.DatabaseGroupResourceID,
+ &schemaGroup.ResourceID,
+ &schemaGroup.Placeholder,
+ &stringExpr,
+ ); err != nil {
+ return nil, errors.Wrapf(err, "failed to scan")
+ }
+ var expression expr.Expr
+ if err := protojson.Unmarshal([]byte(stringExpr), &expression); err != nil {
+ return nil, errors.Wrapf(err, "failed to unmarshal expression")
+ }
+ schemaGroup.Expression = &expression
+ schemaGroups = append(schemaGroups, &schemaGroup)
+ }
+ if err := rows.Err(); err != nil {
+ return nil, errors.Wrapf(err, "failed to scan")
+ }
+ return schemaGroups, nil
+}
+
+// UpdateSchemaGroup updates a schema group.
+func (s *Store) UpdateSchemaGroup(ctx context.Context, updaterPrincipalID int, schemaGroupResourceID string, patch *UpdateSchemaGroupMessage) (*SchemaGroupMessage, error) {
+ set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", updaterPrincipalID)}
+ if v := patch.Placeholder; v != nil {
+ set, args = append(set, fmt.Sprintf("placeholder = $%d", len(args)+1)), append(args, *v)
+ }
+ if v := patch.Expression; v != nil {
+ jsonExpr, err := protojson.Marshal(patch.Expression)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to marshal expression")
+ }
+ set, args = append(set, fmt.Sprintf("expression = $%d", len(args)+1)), append(args, jsonExpr)
+ }
+ args = append(args, schemaGroupResourceID)
+ query := fmt.Sprintf(`
+ UPDATE schema_group SET
+ %s
+ WHERE resource_id = $%d
+ RETURNING id, created_ts, updated_ts, creator_id, updater_id, db_group_resource_id, resource_id, placeholder, expression;
+ `, strings.Join(set, ", "), len(args))
+
+ tx, err := s.db.BeginTx(ctx, nil)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to commit ")
+ }
+
+ var updatedSchemaGroup SchemaGroupMessage
+ var stringExpr string
+ if err := tx.QueryRowContext(
+ ctx,
+ query,
+ args...,
+ ).Scan(
+ &updatedSchemaGroup.ID,
+ &updatedSchemaGroup.CreatedTs,
+ &updatedSchemaGroup.UpdatedTs,
+ &updatedSchemaGroup.CreatorID,
+ &updatedSchemaGroup.UpdaterID,
+ &updatedSchemaGroup.DatabaseGroupResourceID,
+ &updatedSchemaGroup.ResourceID,
+ &updatedSchemaGroup.Placeholder,
+ &stringExpr,
+ ); err != nil {
+ return nil, errors.Wrapf(err, "failed to scan")
+ }
+ if err := tx.Commit(); err != nil {
+ return nil, errors.Wrapf(err, "failed to commit transaction")
+ }
+ var expression expr.Expr
+ if err := protojson.Unmarshal([]byte(stringExpr), &expression); err != nil {
+ return nil, errors.Wrapf(err, "failed to unmarshal expression")
+ }
+ updatedSchemaGroup.Expression = &expression
+ return &updatedSchemaGroup, nil
+}
+
+// CreateSchemaGroup creates a schema group.
+func (s *Store) CreateSchemaGroup(ctx context.Context, creatorPrincipalID int, schemaGroup *SchemaGroupMessage) (*SchemaGroupMessage, error) {
+ query := `
+ INSERT INTO schema_group (
+ creator_id,
+ updater_id,
+ db_resource_id,
+ resource_id,
+ placeholder,
+ expression
+ ) VALUES ($1, $2, $3, $4, $5, $6)
+ RETURNING id, created_ts, updated_ts, creator_id, updater_id, db_group_resource_id, resource_id, placeholder, expression;
+ `
+ jsonExpr, err := protojson.Marshal(schemaGroup.Expression)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to marshal expression")
+ }
+
+ tx, err := s.db.BeginTx(ctx, nil)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to begin transaction")
+ }
+ defer tx.Rollback()
+
+ var insertedSchemaGroup SchemaGroupMessage
+ var stringExpr string
+ if err := tx.QueryRowContext(
+ ctx,
+ query,
+ creatorPrincipalID,
+ creatorPrincipalID,
+ schemaGroup.DatabaseGroupResourceID,
+ schemaGroup.ResourceID,
+ schemaGroup.Placeholder,
+ jsonExpr,
+ ).Scan(
+ &insertedSchemaGroup.ID,
+ &insertedSchemaGroup.CreatedTs,
+ &insertedSchemaGroup.UpdatedTs,
+ &insertedSchemaGroup.CreatorID,
+ &insertedSchemaGroup.UpdaterID,
+ &insertedSchemaGroup.DatabaseGroupResourceID,
+ &insertedSchemaGroup.ResourceID,
+ &insertedSchemaGroup.Placeholder,
+ &stringExpr,
+ ); err != nil {
+ return nil, errors.Wrapf(err, "failed to scan")
+ }
+ if err := tx.Commit(); err != nil {
+ return nil, errors.Wrapf(err, "failed to commit transaction")
+ }
+ var expression expr.Expr
+ if err := protojson.Unmarshal([]byte(stringExpr), &expression); err != nil {
+ return nil, errors.Wrapf(err, "failed to unmarshal expression")
+ }
+ insertedSchemaGroup.Expression = &expression
+ return &insertedSchemaGroup, nil
+}
diff --git a/frontend/src/types/proto/v1/project_service.ts b/frontend/src/types/proto/v1/project_service.ts
index 5d4b08eefb..adcbfcc716 100644
--- a/frontend/src/types/proto/v1/project_service.ts
+++ b/frontend/src/types/proto/v1/project_service.ts
@@ -6136,7 +6136,7 @@ export const ProjectServiceDefinition = {
name: "CreateSchemaGroup",
requestType: CreateSchemaGroupRequest,
requestStream: false,
- responseType: DatabaseGroup,
+ responseType: SchemaGroup,
responseStream: false,
options: {
_unknownFields: {
@@ -6246,7 +6246,7 @@ export const ProjectServiceDefinition = {
name: "UpdateSchemaGroup",
requestType: UpdateSchemaGroupRequest,
requestStream: false,
- responseType: DatabaseGroup,
+ responseType: SchemaGroup,
responseStream: false,
options: {
_unknownFields: {
@@ -6522,11 +6522,11 @@ export interface ProjectServiceImplementation<CallContextExt = {}> {
createSchemaGroup(
request: CreateSchemaGroupRequest,
context: CallContext & CallContextExt,
- ): Promise<DeepPartial<DatabaseGroup>>;
+ ): Promise<DeepPartial<SchemaGroup>>;
updateSchemaGroup(
request: UpdateSchemaGroupRequest,
context: CallContext & CallContextExt,
- ): Promise<DeepPartial<DatabaseGroup>>;
+ ): Promise<DeepPartial<SchemaGroup>>;
deleteSchemaGroup(
request: DeleteSchemaGroupRequest,
context: CallContext & CallContextExt,
@@ -6611,11 +6611,11 @@ export interface ProjectServiceClient<CallOptionsExt = {}> {
createSchemaGroup(
request: DeepPartial<CreateSchemaGroupRequest>,
options?: CallOptions & CallOptionsExt,
- ): Promise<DatabaseGroup>;
+ ): Promise<SchemaGroup>;
updateSchemaGroup(
request: DeepPartial<UpdateSchemaGroupRequest>,
options?: CallOptions & CallOptionsExt,
- ): Promise<DatabaseGroup>;
+ ): Promise<SchemaGroup>;
deleteSchemaGroup(
request: DeepPartial<DeleteSchemaGroupRequest>,
options?: CallOptions & CallOptionsExt,
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 0e7f27b53c..2aa20a2c2d 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -5028,8 +5028,8 @@ TYPE_PROJECT_REPOSITORY_PUSH represents Bytebase receiving a push event from the
| DeleteDatabaseGroup | [DeleteDatabaseGroupRequest](#bytebase-v1-DeleteDatabaseGroupRequest) | [.google.protobuf.Empty](#google-protobuf-Empty) | |
| ListSchemaGroups | [ListSchemaGroupsRequest](#bytebase-v1-ListSchemaGroupsRequest) | [ListSchemaGroupsResponse](#bytebase-v1-ListSchemaGroupsResponse) | |
| GetSchemaGroup | [GetSchemaGroupRequest](#bytebase-v1-GetSchemaGroupRequest) | [SchemaGroup](#bytebase-v1-SchemaGroup) | |
-| CreateSchemaGroup | [CreateSchemaGroupRequest](#bytebase-v1-CreateSchemaGroupRequest) | [DatabaseGroup](#bytebase-v1-DatabaseGroup) | |
-| UpdateSchemaGroup | [UpdateSchemaGroupRequest](#bytebase-v1-UpdateSchemaGroupRequest) | [DatabaseGroup](#bytebase-v1-DatabaseGroup) | |
+| CreateSchemaGroup | [CreateSchemaGroupRequest](#bytebase-v1-CreateSchemaGroupRequest) | [SchemaGroup](#bytebase-v1-SchemaGroup) | |
+| UpdateSchemaGroup | [UpdateSchemaGroupRequest](#bytebase-v1-UpdateSchemaGroupRequest) | [SchemaGroup](#bytebase-v1-SchemaGroup) | |
| DeleteSchemaGroup | [DeleteSchemaGroupRequest](#bytebase-v1-DeleteSchemaGroupRequest) | [.google.protobuf.Empty](#google-protobuf-Empty) | |
diff --git a/proto/generated-go/v1/project_service.pb.go b/proto/generated-go/v1/project_service.pb.go
index 635c0154f1..1e44ae73c5 100644
--- a/proto/generated-go/v1/project_service.pb.go
+++ b/proto/generated-go/v1/project_service.pb.go
@@ -3806,7 +3806,7 @@ var file_v1_project_service_proto_rawDesc = []byte{
0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x4f, 0x50, 0x45, 0x52, 0x41, 0x54, 0x4f, 0x52,
0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x49, 0x4e, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x4f, 0x50,
0x45, 0x52, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x45, 0x58, 0x49, 0x53,
- 0x54, 0x53, 0x10, 0x02, 0x32, 0xf8, 0x1f, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74,
+ 0x54, 0x53, 0x10, 0x02, 0x32, 0xf4, 0x1f, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x68, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x50, 0x72,
0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,
0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65,
@@ -4027,43 +4027,43 @@ var file_v1_project_service_proto_rawDesc = []byte{
0x02, 0x37, 0x12, 0x35, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x70, 0x72,
0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2f, 0x2a, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73,
0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x2f, 0x2a, 0x2f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61,
- 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0xba, 0x01, 0x0a, 0x11, 0x43, 0x72,
+ 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0xb8, 0x01, 0x0a, 0x11, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12,
0x25, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52,
- 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,
- 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x47, 0x72, 0x6f,
- 0x75, 0x70, 0x22, 0x62, 0xda, 0x41, 0x14, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x2c, 0x64, 0x61,
- 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x82, 0xd3, 0xe4, 0x93, 0x02,
- 0x45, 0x3a, 0x0c, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x22,
- 0x35, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x70, 0x72, 0x6f,
- 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2f, 0x2a, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65,
- 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x2f, 0x2a, 0x7d, 0x2f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61,
- 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x12, 0xcb, 0x01, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74,
- 0x65, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x25, 0x2e, 0x62,
- 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74,
- 0x65, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75,
- 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,
- 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x22,
- 0x73, 0xda, 0x41, 0x18, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70,
- 0x2c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3, 0xe4, 0x93,
- 0x02, 0x52, 0x3a, 0x0c, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70,
- 0x32, 0x42, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x67, 0x72,
- 0x6f, 0x75, 0x70, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74,
- 0x73, 0x2f, 0x2a, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x47, 0x72, 0x6f, 0x75,
- 0x70, 0x73, 0x2f, 0x2a, 0x2f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x47, 0x72, 0x6f, 0x75, 0x70,
- 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x98, 0x01, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53,
+ 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,
+ 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x47, 0x72, 0x6f, 0x75, 0x70,
+ 0x22, 0x62, 0xda, 0x41, 0x14, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x2c, 0x64, 0x61, 0x74, 0x61,
+ 0x62, 0x61, 0x73, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x45, 0x3a,
+ 0x0c, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x22, 0x35, 0x2f,
+ 0x76, 0x31, 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x70, 0x72, 0x6f, 0x6a, 0x65,
+ 0x63, 0x74, 0x73, 0x2f, 0x2a, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x47, 0x72,
+ 0x6f, 0x75, 0x70, 0x73, 0x2f, 0x2a, 0x7d, 0x2f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x47, 0x72,
+ 0x6f, 0x75, 0x70, 0x73, 0x12, 0xc9, 0x01, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53,
0x63, 0x68, 0x65, 0x6d, 0x61, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x25, 0x2e, 0x62, 0x79, 0x74,
- 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53,
+ 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53,
0x63, 0x68, 0x65, 0x6d, 0x61, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
- 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
- 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x44, 0xda, 0x41, 0x04, 0x6e, 0x61,
- 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x37, 0x2a, 0x35, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e,
- 0x61, 0x6d, 0x65, 0x3d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2f, 0x2a, 0x2f, 0x64,
- 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x2f, 0x2a, 0x2f,
- 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x2f, 0x2a, 0x7d, 0x42,
- 0x11, 0x5a, 0x0f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f,
- 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x74, 0x1a, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,
+ 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x22, 0x73, 0xda, 0x41, 0x18,
+ 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2c, 0x75, 0x70, 0x64,
+ 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x52, 0x3a, 0x0c,
+ 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x32, 0x42, 0x2f, 0x76,
+ 0x31, 0x2f, 0x7b, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e,
+ 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2f, 0x2a, 0x2f,
+ 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x2f, 0x2a,
+ 0x2f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x2f, 0x2a, 0x7d,
+ 0x12, 0x98, 0x01, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x6d,
+ 0x61, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x25, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,
+ 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x63, 0x68, 0x65, 0x6d,
+ 0x61, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e,
+ 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
+ 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x44, 0xda, 0x41, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x82, 0xd3,
+ 0xe4, 0x93, 0x02, 0x37, 0x2a, 0x35, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d,
+ 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2f, 0x2a, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x62,
+ 0x61, 0x73, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x2f, 0x2a, 0x2f, 0x73, 0x63, 0x68, 0x65,
+ 0x6d, 0x61, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x2f, 0x2a, 0x7d, 0x42, 0x11, 0x5a, 0x0f, 0x67,
+ 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x06,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -4239,8 +4239,8 @@ var file_v1_project_service_proto_depIdxs = []int32{
60, // 92: bytebase.v1.ProjectService.DeleteDatabaseGroup:output_type -> google.protobuf.Empty
52, // 93: bytebase.v1.ProjectService.ListSchemaGroups:output_type -> bytebase.v1.ListSchemaGroupsResponse
54, // 94: bytebase.v1.ProjectService.GetSchemaGroup:output_type -> bytebase.v1.SchemaGroup
- 47, // 95: bytebase.v1.ProjectService.CreateSchemaGroup:output_type -> bytebase.v1.DatabaseGroup
- 47, // 96: bytebase.v1.ProjectService.UpdateSchemaGroup:output_type -> bytebase.v1.DatabaseGroup
+ 54, // 95: bytebase.v1.ProjectService.CreateSchemaGroup:output_type -> bytebase.v1.SchemaGroup
+ 54, // 96: bytebase.v1.ProjectService.UpdateSchemaGroup:output_type -> bytebase.v1.SchemaGroup
60, // 97: bytebase.v1.ProjectService.DeleteSchemaGroup:output_type -> google.protobuf.Empty
70, // [70:98] is the sub-list for method output_type
42, // [42:70] is the sub-list for method input_type
diff --git a/proto/generated-go/v1/project_service_grpc.pb.go b/proto/generated-go/v1/project_service_grpc.pb.go
index dc207b3fae..2daf99b59f 100644
--- a/proto/generated-go/v1/project_service_grpc.pb.go
+++ b/proto/generated-go/v1/project_service_grpc.pb.go
@@ -80,8 +80,8 @@ type ProjectServiceClient interface {
DeleteDatabaseGroup(ctx context.Context, in *DeleteDatabaseGroupRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
ListSchemaGroups(ctx context.Context, in *ListSchemaGroupsRequest, opts ...grpc.CallOption) (*ListSchemaGroupsResponse, error)
GetSchemaGroup(ctx context.Context, in *GetSchemaGroupRequest, opts ...grpc.CallOption) (*SchemaGroup, error)
- CreateSchemaGroup(ctx context.Context, in *CreateSchemaGroupRequest, opts ...grpc.CallOption) (*DatabaseGroup, error)
- UpdateSchemaGroup(ctx context.Context, in *UpdateSchemaGroupRequest, opts ...grpc.CallOption) (*DatabaseGroup, error)
+ CreateSchemaGroup(ctx context.Context, in *CreateSchemaGroupRequest, opts ...grpc.CallOption) (*SchemaGroup, error)
+ UpdateSchemaGroup(ctx context.Context, in *UpdateSchemaGroupRequest, opts ...grpc.CallOption) (*SchemaGroup, error)
DeleteSchemaGroup(ctx context.Context, in *DeleteSchemaGroupRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
}
@@ -318,8 +318,8 @@ func (c *projectServiceClient) GetSchemaGroup(ctx context.Context, in *GetSchema
return out, nil
}
-func (c *projectServiceClient) CreateSchemaGroup(ctx context.Context, in *CreateSchemaGroupRequest, opts ...grpc.CallOption) (*DatabaseGroup, error) {
- out := new(DatabaseGroup)
+func (c *projectServiceClient) CreateSchemaGroup(ctx context.Context, in *CreateSchemaGroupRequest, opts ...grpc.CallOption) (*SchemaGroup, error) {
+ out := new(SchemaGroup)
err := c.cc.Invoke(ctx, ProjectService_CreateSchemaGroup_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
@@ -327,8 +327,8 @@ func (c *projectServiceClient) CreateSchemaGroup(ctx context.Context, in *Create
return out, nil
}
-func (c *projectServiceClient) UpdateSchemaGroup(ctx context.Context, in *UpdateSchemaGroupRequest, opts ...grpc.CallOption) (*DatabaseGroup, error) {
- out := new(DatabaseGroup)
+func (c *projectServiceClient) UpdateSchemaGroup(ctx context.Context, in *UpdateSchemaGroupRequest, opts ...grpc.CallOption) (*SchemaGroup, error) {
+ out := new(SchemaGroup)
err := c.cc.Invoke(ctx, ProjectService_UpdateSchemaGroup_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
@@ -375,8 +375,8 @@ type ProjectServiceServer interface {
DeleteDatabaseGroup(context.Context, *DeleteDatabaseGroupRequest) (*emptypb.Empty, error)
ListSchemaGroups(context.Context, *ListSchemaGroupsRequest) (*ListSchemaGroupsResponse, error)
GetSchemaGroup(context.Context, *GetSchemaGroupRequest) (*SchemaGroup, error)
- CreateSchemaGroup(context.Context, *CreateSchemaGroupRequest) (*DatabaseGroup, error)
- UpdateSchemaGroup(context.Context, *UpdateSchemaGroupRequest) (*DatabaseGroup, error)
+ CreateSchemaGroup(context.Context, *CreateSchemaGroupRequest) (*SchemaGroup, error)
+ UpdateSchemaGroup(context.Context, *UpdateSchemaGroupRequest) (*SchemaGroup, error)
DeleteSchemaGroup(context.Context, *DeleteSchemaGroupRequest) (*emptypb.Empty, error)
mustEmbedUnimplementedProjectServiceServer()
}
@@ -460,10 +460,10 @@ func (UnimplementedProjectServiceServer) ListSchemaGroups(context.Context, *List
func (UnimplementedProjectServiceServer) GetSchemaGroup(context.Context, *GetSchemaGroupRequest) (*SchemaGroup, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetSchemaGroup not implemented")
}
-func (UnimplementedProjectServiceServer) CreateSchemaGroup(context.Context, *CreateSchemaGroupRequest) (*DatabaseGroup, error) {
+func (UnimplementedProjectServiceServer) CreateSchemaGroup(context.Context, *CreateSchemaGroupRequest) (*SchemaGroup, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateSchemaGroup not implemented")
}
-func (UnimplementedProjectServiceServer) UpdateSchemaGroup(context.Context, *UpdateSchemaGroupRequest) (*DatabaseGroup, error) {
+func (UnimplementedProjectServiceServer) UpdateSchemaGroup(context.Context, *UpdateSchemaGroupRequest) (*SchemaGroup, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateSchemaGroup not implemented")
}
func (UnimplementedProjectServiceServer) DeleteSchemaGroup(context.Context, *DeleteSchemaGroupRequest) (*emptypb.Empty, error) {
diff --git a/proto/v1/project_service.proto b/proto/v1/project_service.proto
index 4913fc9a44..2509cc9161 100644
--- a/proto/v1/project_service.proto
+++ b/proto/v1/project_service.proto
@@ -165,7 +165,7 @@ service ProjectService {
option (google.api.method_signature) = "name";
}
- rpc CreateSchemaGroup(CreateSchemaGroupRequest) returns (DatabaseGroup) {
+ rpc CreateSchemaGroup(CreateSchemaGroupRequest) returns (SchemaGroup) {
option (google.api.http) = {
post: "/v1/{parent=projects/*/databaseGroups/*}/schemaGroups"
body: "schema_group"
@@ -173,7 +173,7 @@ service ProjectService {
option (google.api.method_signature) = "parent,databaseGroup";
}
- rpc UpdateSchemaGroup(UpdateSchemaGroupRequest) returns (DatabaseGroup) {
+ rpc UpdateSchemaGroup(UpdateSchemaGroupRequest) returns (SchemaGroup) {
option (google.api.http) = {
patch: "/v1/{schema_group.name=projects/*/databaseGroups/*/schemaGroups/*}"
body: "schema_group"