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: rename activity to event (#16266)
p0ny2f04efa295a7
diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.goindex 06a1f54d04..73ff2cd2ff 100644--- a/backend/api/v1/project_service.go+++ b/backend/api/v1/project_service.go@@ -841,7 +841,7 @@ func (s *ProjectService) UpdateWebhook(ctx context.Context, request *v1pb.Updateif len(types) == 0 {return nil, status.Errorf(codes.InvalidArgument, "notification types should not be empty")}- update.ActivityList = types+ update.Events = typescase "direct_message":update.Payload = &storepb.ProjectWebhookPayload{DirectMessage: request.Webhook.DirectMessage,@@ -948,17 +948,17 @@ func (s *ProjectService) TestWebhook(ctx context.Context, request *v1pb.TestWebherr = webhookplugin.Post(webhook.Type,webhookplugin.Context{- URL: webhook.URL,- Level: webhookplugin.WebhookInfo,- ActivityType: string(base.EventTypeIssueCreate),- Title: fmt.Sprintf("Test webhook %q", webhook.Title),- TitleZh: fmt.Sprintf("测试 webhook %q", webhook.Title),- Description: "This is a test",- Link: fmt.Sprintf("%s/projects/%s/webhooks/%s", setting.ExternalUrl, project.ResourceID, fmt.Sprintf("%s-%d", slug.Make(webhook.Title), webhook.ID)),- ActorID: base.SystemBotID,- ActorName: "Bytebase",- ActorEmail: s.store.GetSystemBotUser(ctx).Email,- CreatedTS: time.Now().Unix(),+ URL: webhook.URL,+ Level: webhookplugin.WebhookInfo,+ EventType: string(base.EventTypeIssueCreate),+ Title: fmt.Sprintf("Test webhook %q", webhook.Title),+ TitleZh: fmt.Sprintf("测试 webhook %q", webhook.Title),+ Description: "This is a test",+ Link: fmt.Sprintf("%s/projects/%s/webhooks/%s", setting.ExternalUrl, project.ResourceID, fmt.Sprintf("%s-%d", slug.Make(webhook.Title), webhook.ID)),+ ActorID: base.SystemBotID,+ ActorName: "Bytebase",+ ActorEmail: s.store.GetSystemBotUser(ctx).Email,+ CreatedTS: time.Now().Unix(),Issue: &webhookplugin.Issue{ID: 1,Name: "Test issue",@@ -991,10 +991,10 @@ func convertToStoreProjectWebhookMessage(webhook *v1pb.Webhook) (*store.ProjectWreturn nil, err}return &store.ProjectWebhookMessage{- Type: tp,- URL: webhook.Url,- Title: webhook.Title,- ActivityList: activityTypes,+ Type: tp,+ URL: webhook.Url,+ Title: webhook.Title,+ Events: activityTypes,Payload: &storepb.ProjectWebhookPayload{DirectMessage: webhook.DirectMessage,},@@ -1266,7 +1266,7 @@ func convertToProject(projectMessage *store.ProjectMessage) *v1pb.Project {Type: convertWebhookTypeString(webhook.Type),Title: webhook.Title,Url: webhook.URL,- NotificationTypes: convertNotificationTypeStrings(webhook.ActivityList),+ NotificationTypes: convertNotificationTypeStrings(webhook.Events),DirectMessage: webhook.Payload.GetDirectMessage(),})}diff --git a/backend/component/webhook/manager.go b/backend/component/webhook/manager.goindex 499a496ab9..988f1a22b9 100644--- a/backend/component/webhook/manager.go+++ b/backend/component/webhook/manager.go@@ -271,12 +271,12 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, even}webhookCtx = webhook.Context{- Level: level,- ActivityType: string(eventType),- Title: title,- TitleZh: titleZh,- Issue: nil,- Rollout: nil,+ Level: level,+ EventType: string(eventType),+ Title: title,+ TitleZh: titleZh,+ Issue: nil,+ Rollout: nil,Project: &webhook.Project{Name: common.FormatProject(e.Project.ResourceID),Title: e.Project.Title,@@ -346,7 +346,7 @@ func (m *Manager) postWebhookList(ctx context.Context, webhookCtx *webhook.Conteslog.Warn("Failed to post webhook event on activity",slog.String("webhook type", hook.Type),slog.String("webhook name", hook.Title),- slog.String("activity type", webhookCtx.ActivityType),+ slog.String("activity type", webhookCtx.EventType),slog.String("title", webhookCtx.Title),log.BBError(err))returndiff --git a/backend/migrator/migration/3.7/0010##rename_activity_list_to_event_list.sql b/backend/migrator/migration/3.7/0010##rename_activity_list_to_event_list.sqlnew file mode 100644index 0000000000..f94b985e5e--- /dev/null+++ b/backend/migrator/migration/3.7/0010##rename_activity_list_to_event_list.sql@@ -0,0 +1 @@+ALTER TABLE project_webhook RENAME COLUMN activity_list TO event_list;\ No newline at end of filediff --git a/backend/migrator/migration/LATEST.sql b/backend/migrator/migration/LATEST.sqlindex 93f514a6c3..2a4939f9e3 100644--- a/backend/migrator/migration/LATEST.sql+++ b/backend/migrator/migration/LATEST.sql@@ -88,7 +88,7 @@ CREATE TABLE project_webhook (type text NOT NULL CHECK (type LIKE 'bb.plugin.webhook.%'),name text NOT NULL,url text NOT NULL,- activity_list text ARRAY NOT NULL,+ event_list text ARRAY NOT NULL,payload jsonb NOT NULL DEFAULT '{}');diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.goindex b37f792948..bdc9e45778 100644--- a/backend/migrator/migrator_test.go+++ b/backend/migrator/migrator_test.go@@ -12,7 +12,7 @@ import (func TestLatestVersion(t *testing.T) {files, err := getSortedVersionedFiles()require.NoError(t, err)- require.Equal(t, semver.MustParse("3.7.9"), *files[len(files)-1].version)+ require.Equal(t, semver.MustParse("3.7.10"), *files[len(files)-1].version)}func TestVersionUnique(t *testing.T) {diff --git a/backend/plugin/webhook/webhook.go b/backend/plugin/webhook/webhook.goindex e6a4e5ab0f..6d5036d666 100644--- a/backend/plugin/webhook/webhook.go+++ b/backend/plugin/webhook/webhook.go@@ -78,22 +78,22 @@ type Project struct {// Context is the context of webhook.type Context struct {- URL string- Level Level- ActivityType string- Title string- TitleZh string- Description string- Link string- ActorID int- ActorName string- ActorEmail string- CreatedTS int64- Issue *Issue- Rollout *Rollout- Stage *Stage- Project *Project- TaskResult *TaskResult+ URL string+ Level Level+ EventType string+ Title string+ TitleZh string+ Description string+ Link string+ ActorID int+ ActorName string+ ActorEmail string+ CreatedTS int64+ Issue *Issue+ Rollout *Rollout+ Stage *Stage+ Project *Project+ TaskResult *TaskResult// End users that should be mentioned.MentionEndUsers []*store.UserMessageMentionUsersByPhone []stringdiff --git a/backend/store/project_webhook.go b/backend/store/project_webhook.goindex 736d42ce1a..3d27672555 100644--- a/backend/store/project_webhook.go+++ b/backend/store/project_webhook.go@@ -23,8 +23,8 @@ type ProjectWebhookMessage struct {Title string// URL is the webhook URL.URL string- // ActivityList is the list of activities that the webhook is interested in.- ActivityList []string+ // Events is the list of activities that the webhook is interested in.+ Events []string// Output only fields.//// ID is the unique identifier of the project webhook.@@ -39,9 +39,9 @@ type UpdateProjectWebhookMessage struct {Title *string// URL is the webhook URL.URL *string- // ActivityList is the list of activities that the webhook is interested in.- ActivityList []string- Payload *storepb.ProjectWebhookPayload+ // Events is the list of activities that the webhook is interested in.+ Events []string+ Payload *storepb.ProjectWebhookPayload}// FindProjectWebhookMessage is the message for finding project webhooks,@@ -77,12 +77,12 @@ func (s *Store) CreateProjectWebhookV2(ctx context.Context, projectID string, cr}projectWebhook := ProjectWebhookMessage{- Type: create.Type,- Title: create.Title,- URL: create.URL,- ActivityList: create.ActivityList,- ProjectID: create.ProjectID,- Payload: create.Payload,+ Type: create.Type,+ Title: create.Title,+ URL: create.URL,+ Events: create.Events,+ ProjectID: create.ProjectID,+ Payload: create.Payload,}tx, err := s.db.BeginTx(ctx, nil)@@ -95,7 +95,7 @@ func (s *Store) CreateProjectWebhookV2(ctx context.Context, projectID string, crcreate.Type,create.Title,create.URL,- create.ActivityList,+ create.Events,payload,).Scan(&projectWebhook.ID,@@ -170,7 +170,7 @@ func (s *Store) UpdateProjectWebhookV2(ctx context.Context, projectResourceID stif v := update.URL; v != nil {set, args = append(set, fmt.Sprintf("url = $%d", len(args)+1)), append(args, *v)}- if v := update.ActivityList; v != nil {+ if v := update.Events; v != nil {set, args = append(set, fmt.Sprintf("activity_list = $%d", len(args)+1)), append(args, v)}if v := update.Payload; v != nil {@@ -210,7 +210,7 @@ func (s *Store) UpdateProjectWebhookV2(ctx context.Context, projectResourceID st}return nil, err}- if err := txtArray.AssignTo(&projectWebhook.ActivityList); err != nil {+ if err := txtArray.AssignTo(&projectWebhook.Events); err != nil {return nil, err}if err := common.ProtojsonUnmarshaler.Unmarshal(payload, projectWebhook.Payload); err != nil {@@ -293,7 +293,7 @@ func (*Store) findProjectWebhookImplV2(ctx context.Context, txn *sql.Tx, find *Freturn nil, err}- if err := txtArray.AssignTo(&projectWebhook.ActivityList); err != nil {+ if err := txtArray.AssignTo(&projectWebhook.Events); err != nil {return nil, err}if err := common.ProtojsonUnmarshaler.Unmarshal(payload, projectWebhook.Payload); err != nil {@@ -301,7 +301,7 @@ func (*Store) findProjectWebhookImplV2(ctx context.Context, txn *sql.Tx, find *F}if v := find.EventType; v != nil {- for _, activity := range projectWebhook.ActivityList {+ for _, activity := range projectWebhook.Events {if base.EventType(activity) == *v {projectWebhooks = append(projectWebhooks, &projectWebhook)break