Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: enforce unique branch name (#9385)
Danny Xu24069af73ac8
diff --git a/backend/api/gitops/webhook.go b/backend/api/gitops/webhook.goindex 20b3649f9a..67f9abed67 100644--- a/backend/api/gitops/webhook.go+++ b/backend/api/gitops/webhook.go@@ -1911,7 +1911,7 @@ func (s *Service) prepareIssueFromSDLFile(ctx context.Context, oauthContext *comsheet, err := s.store.CreateSheet(ctx, &store.SheetMessage{CreatorID: api.SystemBotID,ProjectUID: repoInfo.project.UID,- Name: file,+ Title: file,Statement: sdl,Visibility: store.ProjectSheet,Source: store.SheetFromBytebaseArtifact,@@ -1984,7 +1984,7 @@ func (s *Service) prepareIssueFromFile(sheet, err := s.store.CreateSheet(ctx, &store.SheetMessage{CreatorID: api.SystemBotID,ProjectUID: repoInfo.project.UID,- Name: fileInfo.item.FileName,+ Title: fileInfo.item.FileName,Statement: content,Visibility: store.ProjectSheet,Source: store.SheetFromBytebaseArtifact,@@ -2021,7 +2021,7 @@ func (s *Service) prepareIssueFromFile(sheet, err := s.store.CreateSheet(ctx, &store.SheetMessage{CreatorID: api.SystemBotID,ProjectUID: repoInfo.project.UID,- Name: fileInfo.item.FileName,+ Title: fileInfo.item.FileName,Statement: migrationFile.Statement,Visibility: store.ProjectSheet,Source: store.SheetFromBytebaseArtifact,@@ -2072,7 +2072,7 @@ func (s *Service) prepareIssueFromFile(sheet, err := s.store.CreateSheet(ctx, &store.SheetMessage{CreatorID: api.SystemBotID,ProjectUID: repoInfo.project.UID,- Name: fileInfo.item.FileName,+ Title: fileInfo.item.FileName,Statement: content,Visibility: store.ProjectSheet,Source: store.SheetFromBytebaseArtifact,@@ -2150,7 +2150,7 @@ func (s *Service) tryUpdateTasksFromModifiedFile(ctx context.Context, databasessheet, err := s.store.CreateSheet(ctx, &store.SheetMessage{CreatorID: api.SystemBotID,ProjectUID: issue.Project.UID,- Name: fileName,+ Title: fileName,Statement: statement,Visibility: store.ProjectSheet,Source: store.SheetFromBytebaseArtifact,diff --git a/backend/api/v1/rollout_service.go b/backend/api/v1/rollout_service.goindex 9223a064d3..950aaa523e 100644--- a/backend/api/v1/rollout_service.go+++ b/backend/api/v1/rollout_service.go@@ -1254,7 +1254,7 @@ func (s *RolloutService) createPipeline(ctx context.Context, project *store.Projsheet, err := s.store.CreateSheet(ctx, &store.SheetMessage{CreatorID: api.SystemBotID,ProjectUID: project.UID,- Name: fmt.Sprintf("Sheet for task %v", c.Name),+ Title: fmt.Sprintf("Sheet for task %v", c.Name),Statement: c.Statement,Visibility: store.ProjectSheet,Source: store.SheetFromBytebaseArtifact,diff --git a/backend/api/v1/rollout_service_task.go b/backend/api/v1/rollout_service_task.goindex 47cc135134..2a339c8a3f 100644--- a/backend/api/v1/rollout_service_task.go+++ b/backend/api/v1/rollout_service_task.go@@ -215,7 +215,7 @@ func getTaskCreatesFromCreateDatabaseConfig(ctx context.Context, s *store.Store,sheet, err := s.CreateSheet(ctx, &store.SheetMessage{CreatorID: api.SystemBotID,ProjectUID: project.UID,- Name: fmt.Sprintf("Sheet for creating database %v", databaseName),+ Title: fmt.Sprintf("Sheet for creating database %v", databaseName),Statement: statement,Visibility: store.ProjectSheet,Source: store.SheetFromBytebaseArtifact,diff --git a/backend/api/v1/schema_design_service.go b/backend/api/v1/schema_design_service.goindex ea3667ad61..0766a87317 100644--- a/backend/api/v1/schema_design_service.go+++ b/backend/api/v1/schema_design_service.go@@ -172,6 +172,18 @@ func (s *SchemaDesignService) CreateSchemaDesign(ctx context.Context, request *vreturn nil, status.Errorf(codes.Internal, "principal ID not found")}schemaDesign := request.SchemaDesign+ if schemaDesign == nil {+ return nil, status.Errorf(codes.InvalidArgument, "empty branch design")+ }++ schemaDesignSheetType := storepb.SheetPayload_SCHEMA_DESIGN.String()+ sheet, err := s.store.GetSheet(ctx, &store.FindSheetMessage{ProjectUID: &project.UID, Title: &schemaDesign.Title, PayloadType: &schemaDesignSheetType}, principalID)+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to get existing branch design, error %v", err)+ }+ if sheet != nil {+ return nil, status.Errorf(codes.FailedPrecondition, "branch %q has already existed", schemaDesign.Title)+ }// Branch protection check.if err := s.checkProtectionRules(ctx, project, schemaDesign, principalID); err != nil {@@ -247,7 +259,7 @@ func (s *SchemaDesignService) CreateSchemaDesign(ctx context.Context, request *vschemaDesignSheetPayload.SchemaDesign.BaselineSheetId = fmt.Sprintf("%d", baselineSheetUID)} else if schemaDesignType == storepb.SheetPayload_SchemaDesign_PERSONAL_DRAFT {baselineSheetCreate := &store.SheetMessage{- Name: schemaDesign.Title,+ Title: schemaDesign.Title,ProjectUID: project.UID,DatabaseUID: &database.UID,Statement: schemaDesign.BaselineSchema,@@ -270,7 +282,7 @@ func (s *SchemaDesignService) CreateSchemaDesign(ctx context.Context, request *v}sheetCreate := &store.SheetMessage{- Name: schemaDesign.Title,+ Title: schemaDesign.Title,ProjectUID: project.UID,DatabaseUID: &database.UID,Statement: schema,@@ -281,7 +293,7 @@ func (s *SchemaDesignService) CreateSchemaDesign(ctx context.Context, request *vUpdaterID: principalID,Payload: schemaDesignSheetPayload,}- sheet, err := s.store.CreateSheet(ctx, sheetCreate)+ sheet, err = s.store.CreateSheet(ctx, sheetCreate)if err != nil {return nil, status.Errorf(codes.Internal, fmt.Sprintf("failed to create sheet: %v", err))}@@ -389,7 +401,7 @@ func (s *SchemaDesignService) UpdateSchemaDesign(ctx context.Context, request *v}if slices.Contains(request.UpdateMask.Paths, "title") {- sheetUpdate.Name = &schemaDesign.Title+ sheetUpdate.Title = &schemaDesign.Title}if slices.Contains(request.UpdateMask.Paths, "schema") {sheetUpdate.Statement = &schemaDesign.Schema@@ -741,7 +753,7 @@ func (s *SchemaDesignService) convertSheetToSchemaDesign(ctx context.Context, sh}schemaDesign := &v1pb.SchemaDesign{Name: name,- Title: sheet.Name,+ Title: sheet.Title,Etag: "",Schema: "",SchemaMetadata: nil,diff --git a/backend/api/v1/sheet_service.go b/backend/api/v1/sheet_service.goindex 80186b3d7d..22cddd9ad4 100644--- a/backend/api/v1/sheet_service.go+++ b/backend/api/v1/sheet_service.go@@ -163,7 +163,7 @@ func (s *SheetService) GetSheet(ctx context.Context, request *v1pb.GetSheetRequereturn nil, status.Errorf(codes.Internal, fmt.Sprintf("failed to check access with error: %v", err))}if !canAccess {- return nil, status.Errorf(codes.PermissionDenied, "cannot access sheet %s", sheet.Name)+ return nil, status.Errorf(codes.PermissionDenied, "cannot access sheet %s", sheet.Title)}v1pbSheet, err := s.convertToAPISheetMessage(ctx, sheet)@@ -276,7 +276,7 @@ func (s *SheetService) SearchSheets(ctx context.Context, request *v1pb.SearchShereturn nil, status.Errorf(codes.Internal, fmt.Sprintf("failed to check access with error: %v", err))}if !canAccess {- slog.Warn("cannot access sheet", slog.String("name", sheet.Name))+ slog.Warn("cannot access sheet", slog.String("name", sheet.Title))continue}v1pbSheet, err := s.convertToAPISheetMessage(ctx, sheet)@@ -347,7 +347,7 @@ func (s *SheetService) UpdateSheet(ctx context.Context, request *v1pb.UpdateSheereturn nil, status.Errorf(codes.Internal, fmt.Sprintf("failed to check access with error: %v", err))}if !canAccess {- return nil, status.Errorf(codes.PermissionDenied, "cannot write sheet %s", sheet.Name)+ return nil, status.Errorf(codes.PermissionDenied, "cannot write sheet %s", sheet.Title)}sheetPatch := &store.PatchSheetMessage{@@ -358,7 +358,7 @@ func (s *SheetService) UpdateSheet(ctx context.Context, request *v1pb.UpdateSheefor _, path := range request.UpdateMask.Paths {switch path {case "title":- sheetPatch.Name = &request.Sheet.Title+ sheetPatch.Title = &request.Sheet.Titlecase "content":statement := string(request.Sheet.Content)sheetPatch.Statement = &statement@@ -423,7 +423,7 @@ func (s *SheetService) DeleteSheet(ctx context.Context, request *v1pb.DeleteSheereturn nil, status.Errorf(codes.Internal, fmt.Sprintf("failed to check access with error: %v", err))}if !canAccess {- return nil, status.Errorf(codes.PermissionDenied, "cannot write sheet %s", sheet.Name)+ return nil, status.Errorf(codes.PermissionDenied, "cannot write sheet %s", sheet.Title)}if err := s.store.DeleteSheet(ctx, sheetUID); err != nil {@@ -455,7 +455,7 @@ func (s *SheetService) UpdateSheetOrganizer(ctx context.Context, request *v1pb.Ureturn nil, status.Errorf(codes.Internal, fmt.Sprintf("failed to check access with error: %v", err))}if !canAccess {- return nil, status.Errorf(codes.PermissionDenied, "cannot access sheet %s", sheet.Name)+ return nil, status.Errorf(codes.PermissionDenied, "cannot access sheet %s", sheet.Title)}principalID, ok := ctx.Value(common.PrincipalIDContextKey).(int)@@ -655,7 +655,7 @@ func (s *SheetService) convertToAPISheetMessage(ctx context.Context, sheet *storreturn &v1pb.Sheet{Name: fmt.Sprintf("%s%s/%s%d", common.ProjectNamePrefix, project.ResourceID, common.SheetIDPrefix, sheet.UID),Database: databaseParent,- Title: sheet.Name,+ Title: sheet.Title,Creator: fmt.Sprintf("users/%s", creator.Email),CreateTime: timestamppb.New(sheet.CreatedTime),UpdateTime: timestamppb.New(sheet.UpdatedTime),@@ -700,7 +700,7 @@ func convertToStoreSheetMessage(projectUID int, databaseUID *int, creatorID int,ProjectUID: projectUID,DatabaseUID: databaseUID,CreatorID: creatorID,- Name: sheet.Title,+ Title: sheet.Title,Statement: string(sheet.Content),Visibility: visibility,Source: source,diff --git a/backend/runner/rollbackrun/runner.go b/backend/runner/rollbackrun/runner.goindex 01fdd772d3..90fbd1d1e1 100644--- a/backend/runner/rollbackrun/runner.go+++ b/backend/runner/rollbackrun/runner.go@@ -147,7 +147,7 @@ func (r *Runner) generateOracleRollbackSQL(ctx context.Context, task *store.Tasksheet, err := r.store.CreateSheet(ctx, &store.SheetMessage{CreatorID: api.SystemBotID,ProjectUID: project.UID,- Name: fmt.Sprintf("Sheet for rolling back task %v", task.ID),+ Title: fmt.Sprintf("Sheet for rolling back task %v", task.ID),Statement: rollbackStatement,Visibility: store.ProjectSheet,Source: store.SheetFromBytebaseArtifact,@@ -234,7 +234,7 @@ func (r *Runner) generateMySQLRollbackSQL(ctx context.Context, task *store.TaskMsheet, err := r.store.CreateSheet(ctx, &store.SheetMessage{CreatorID: api.SystemBotID,ProjectUID: project.UID,- Name: fmt.Sprintf("Sheet for rolling back task %d", task.ID),+ Title: fmt.Sprintf("Sheet for rolling back task %d", task.ID),Statement: rollbackStatement,Visibility: store.ProjectSheet,Source: store.SheetFromBytebaseArtifact,diff --git a/backend/server/onboard.go b/backend/server/onboard.goindex 9008caef70..0ab7cd3c7d 100644--- a/backend/server/onboard.go+++ b/backend/server/onboard.go@@ -178,7 +178,7 @@ func (s *Server) generateOnboardingData(ctx context.Context, user *store.UserMesCreatorID: userID,ProjectUID: project.UID,DatabaseUID: &prodDatabase.UID,- Name: "Sample Sheet",+ Title: "Sample Sheet",Statement: "SELECT * FROM salary;",Visibility: store.ProjectSheet,Source: store.SheetFromBytebase,@@ -196,7 +196,7 @@ func (s *Server) generateOnboardingData(ctx context.Context, user *store.UserMesProjectUID: project.UID,DatabaseUID: &testDatabase.UID,- Name: "Alter table to test sample instance for sample issue",+ Title: "Alter table to test sample instance for sample issue",Statement: "ALTER TABLE employee ADD COLUMN IF NOT EXISTS email TEXT DEFAULT '';",Visibility: store.ProjectSheet,Source: store.SheetFromBytebaseArtifact,@@ -212,7 +212,7 @@ func (s *Server) generateOnboardingData(ctx context.Context, user *store.UserMesProjectUID: project.UID,DatabaseUID: &prodDatabase.UID,- Name: "Alter table to prod sample instance for sample issue",+ Title: "Alter table to prod sample instance for sample issue",Statement: "ALTER TABLE employee ADD COLUMN IF NOT EXISTS email TEXT DEFAULT '';",Visibility: store.ProjectSheet,Source: store.SheetFromBytebaseArtifact,diff --git a/backend/store/sheet.go b/backend/store/sheet.goindex 19678e976c..2185007d8a 100644--- a/backend/store/sheet.go+++ b/backend/store/sheet.go@@ -55,7 +55,7 @@ type SheetMessage struct {CreatorID intUpdaterID int- Name string+ Title stringStatement stringVisibility SheetVisibilitySource SheetSource@@ -98,7 +98,7 @@ type FindSheetMessage struct {DatabaseUID *int// Domain fields- Name *string+ Title *stringVisibilities []SheetVisibilitySource *SheetSourceNotSource *SheetSource@@ -119,7 +119,7 @@ type FindSheetMessage struct {type PatchSheetMessage struct {UID intUpdaterID int- Name *string+ Title *stringStatement *stringVisibility *stringProjectUID *int@@ -188,6 +188,9 @@ func (s *Store) ListSheets(ctx context.Context, find *FindSheetMessage, currentPif v := find.ProjectUID; v != nil {where, args = append(where, fmt.Sprintf("sheet.project_id = $%d", len(args)+1)), append(args, *v)}+ if v := find.Title; v != nil {+ where, args = append(where, fmt.Sprintf("sheet.name = $%d", len(args)+1)), append(args, *v)+ }if v := find.DatabaseUID; v != nil {where, args = append(where, fmt.Sprintf("sheet.database_id = $%d", len(args)+1)), append(args, *v)}@@ -278,7 +281,7 @@ func (s *Store) ListSheets(ctx context.Context, find *FindSheetMessage, currentP&sheet.updatedTs,&sheet.ProjectUID,&sheet.DatabaseUID,- &sheet.Name,+ &sheet.Title,&sheet.Statement,&sheet.Visibility,&sheet.Source,@@ -351,7 +354,7 @@ func (s *Store) CreateSheet(ctx context.Context, create *SheetMessage) (*SheetMecreate.CreatorID,create.ProjectUID,create.DatabaseUID,- create.Name,+ create.Title,create.Statement,create.Visibility,create.Source,@@ -421,7 +424,7 @@ func (s *Store) DeleteSheet(ctx context.Context, sheetUID int) error {// patchSheetImpl updates a sheet's name/statement/visibility/payload/database_id/project_id.func patchSheetImpl(ctx context.Context, tx *Tx, patch *PatchSheetMessage) (*SheetMessage, error) {set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}- if v := patch.Name; v != nil {+ if v := patch.Title; v != nil {set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)}if v := patch.Statement; v != nil {@@ -466,7 +469,7 @@ func patchSheetImpl(ctx context.Context, tx *Tx, patch *PatchSheetMessage) (*She&sheet.updatedTs,&sheet.ProjectUID,&databaseID,- &sheet.Name,+ &sheet.Title,&sheet.Statement,&sheet.Visibility,&sheet.Source,