Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Lint fix: add comments for publics and use CamelCases for constants (part1). (#92)
spinningbotfc35bec0db53
diff --git a/api/activity.go b/api/activity.goindex fd1a33f180..b9f3513d6c 100644--- a/api/activity.go+++ b/api/activity.go@@ -7,29 +7,47 @@ import ("github.com/bytebase/bytebase/common")-// Activity type+// ActivityType is the type for an activity.type ActivityType stringconst (- // Issue related- ActivityIssueCreate ActivityType = "bb.issue.create"- ActivityIssueCommentCreate ActivityType = "bb.issue.comment.create"- ActivityIssueFieldUpdate ActivityType = "bb.issue.field.update"- ActivityIssueStatusUpdate ActivityType = "bb.issue.status.update"+ // Issue related.++ // ActivityIssueCreate is the type for creating issues.+ ActivityIssueCreate ActivityType = "bb.issue.create"+ // ActivityIssueCommentCreate is the type for creating issue comments.+ ActivityIssueCommentCreate ActivityType = "bb.issue.comment.create"+ // ActivityIssueFieldUpdate is the type for updating issue fields.+ ActivityIssueFieldUpdate ActivityType = "bb.issue.field.update"+ // ActivityIssueStatusUpdate is the type for updating issue status.+ ActivityIssueStatusUpdate ActivityType = "bb.issue.status.update"+ // ActivityPipelineTaskStatusUpdate is the type for updating pipeline task status.ActivityPipelineTaskStatusUpdate ActivityType = "bb.pipeline.task.status.update"- ActivityPipelineTaskFileCommit ActivityType = "bb.pipeline.task.file.commit"+ // ActivityPipelineTaskFileCommit is the type for committing pipeline task file.+ ActivityPipelineTaskFileCommit ActivityType = "bb.pipeline.task.file.commit"// Member related- ActivityMemberCreate ActivityType = "bb.member.create"++ // ActivityMemberCreate is the type for creating members.+ ActivityMemberCreate ActivityType = "bb.member.create"+ // ActivityMemberRoleUpdate is the type for updating member roles.ActivityMemberRoleUpdate ActivityType = "bb.member.role.update"- ActivityMemberActivate ActivityType = "bb.member.activate"+ // ActivityMemberActivate is the type for activating members.+ ActivityMemberActivate ActivityType = "bb.member.activate"+ // ActivityMemberDeactivate is the type for deactivating members.ActivityMemberDeactivate ActivityType = "bb.member.deactivate"// Project related- ActivityProjectRepositoryPush ActivityType = "bb.project.repository.push"++ // ActivityProjectRepositoryPush is the type for pushing repositories.+ ActivityProjectRepositoryPush ActivityType = "bb.project.repository.push"+ // ActivityProjectDatabaseTransfer is the type for transfering databases.ActivityProjectDatabaseTransfer ActivityType = "bb.project.database.transfer"- ActivityProjectMemberCreate ActivityType = "bb.project.member.create"- ActivityProjectMemberDelete ActivityType = "bb.project.member.delete"+ // ActivityProjectMemberCreate is the type for creating project members.+ ActivityProjectMemberCreate ActivityType = "bb.project.member.create"+ // ActivityProjectMemberDelete is the type for deleting project members.+ ActivityProjectMemberDelete ActivityType = "bb.project.member.delete"+ // ActivityProjectMemberRoleUpdate is the type for updating project member roles.ActivityProjectMemberRoleUpdate ActivityType = "bb.project.member.role.update")@@ -69,26 +87,31 @@ func (e ActivityType) String() string {return "bb.activity.unknown"}+// ActivityLevel is the level of activities.type ActivityLevel stringconst (- ACTIVITY_INFO ActivityLevel = "INFO"- ACTIVITY_WARN ActivityLevel = "WARN"- ACTIVITY_ERROR ActivityLevel = "ERROR"+ // ActivityInfo is the INFO level of activities.+ ActivityInfo ActivityLevel = "INFO"+ // ActivityWarn is the WARN level of activities.+ ActivityWarn ActivityLevel = "WARN"+ // ActivityError is the ERROR level of activities.+ ActivityError ActivityLevel = "ERROR")func (e ActivityLevel) String() string {switch e {- case ACTIVITY_INFO:+ case ActivityInfo:return "INFO"- case ACTIVITY_WARN:+ case ActivityWarn:return "WARN"- case ACTIVITY_ERROR:+ case ActivityError:return "ERROR"}return "UNKNOWN"}+// ActivityIssueCreatePayload is the API message payloads for creating issues.// These payload types are only used when marshalling to the json format for saving into the database.// So we annotate with json tag using camelCase naming which is consistent with normal// json naming convention. More importantly, frontend code can simply use JSON.parse to@@ -100,11 +123,13 @@ type ActivityIssueCreatePayload struct {RollbackIssueID int `json:"rollbackIssueId,omitempty"`}+// ActivityIssueCommentCreatePayload is the API message payloads for creating issue comments.type ActivityIssueCommentCreatePayload struct {// Used by inbox to display info without paying the join costIssueName string `json:"issueName"`}+// ActivityIssueFieldUpdatePayload is the API message payloads for updating issue fields.type ActivityIssueFieldUpdatePayload struct {FieldID IssueFieldID `json:"fieldId"`OldValue string `json:"oldValue,omitempty"`@@ -113,6 +138,7 @@ type ActivityIssueFieldUpdatePayload struct {IssueName string `json:"issueName"`}+// ActivityIssueStatusUpdatePayload is the API message payloads for updating issue status.type ActivityIssueStatusUpdatePayload struct {OldStatus IssueStatus `json:"oldStatus,omitempty"`NewStatus IssueStatus `json:"newStatus,omitempty"`@@ -120,6 +146,7 @@ type ActivityIssueStatusUpdatePayload struct {IssueName string `json:"issueName"`}+// ActivityPipelineTaskStatusUpdatePayload is the API message payloads for updating pipeline task status.type ActivityPipelineTaskStatusUpdatePayload struct {TaskID int `json:"taskId"`OldStatus TaskStatus `json:"oldStatus,omitempty"`@@ -129,6 +156,7 @@ type ActivityPipelineTaskStatusUpdatePayload struct {TaskName string `json:"taskName"`}+// ActivityPipelineTaskFileCommitPayload is the API message payloads for committing pipeline task files.type ActivityPipelineTaskFileCommitPayload struct {TaskID int `json:"taskId"`VCSInstanceURL string `json:"vcsInstanceUrl,omitempty"`@@ -138,6 +166,7 @@ type ActivityPipelineTaskFileCommitPayload struct {CommitID string `json:"commitId,omitempty"`}+// ActivityMemberCreatePayload is the API message payloads for creating members.type ActivityMemberCreatePayload struct {PrincipalID int `json:"principalId"`PrincipalName string `json:"principalName"`@@ -146,6 +175,7 @@ type ActivityMemberCreatePayload struct {Role Role `json:"role"`}+// ActivityMemberRoleUpdatePayload is the API message payloads for updating member roles.type ActivityMemberRoleUpdatePayload struct {PrincipalID int `json:"principalId"`PrincipalName string `json:"principalName"`@@ -154,6 +184,7 @@ type ActivityMemberRoleUpdatePayload struct {NewRole Role `json:"newRole"`}+// ActivityMemberActivateDeactivatePayload is the API message payloads for activating or deactivating members.type ActivityMemberActivateDeactivatePayload struct {PrincipalID int `json:"principalId"`PrincipalName string `json:"principalName"`@@ -161,6 +192,7 @@ type ActivityMemberActivateDeactivatePayload struct {Role Role `json:"role"`}+// ActivityProjectRepositoryPushPayload is the API message payloads for pushing repositories.type ActivityProjectRepositoryPushPayload struct {VCSPushEvent common.VCSPushEvent `json:"pushEvent"`// Used by activity table to display info without paying the join cost@@ -169,12 +201,14 @@ type ActivityProjectRepositoryPushPayload struct {IssueName string `json:"issueName,omitempty"`}+// ActivityProjectDatabaseTransferPayload is the API message payloads for transfering databases.type ActivityProjectDatabaseTransferPayload struct {DatabaseID int `json:"databaseId,omitempty"`// Used by activity table to display info without paying the join costDatabaseName string `json:"databaseName,omitempty"`}+// Activity is the API message for an activity.type Activity struct {ID int `jsonapi:"primary,activity"`@@ -197,6 +231,7 @@ type Activity struct {Payload string `jsonapi:"attr,payload"`}+// ActivityCreate is the API message for creating an activity.type ActivityCreate struct {// Standard fields// Value is assigned from the jwt subject field passed by the client.@@ -210,6 +245,7 @@ type ActivityCreate struct {Payload string `jsonapi:"attr,payload"`}+// ActivityFind is the API message for finding activities.type ActivityFind struct {ID *int@@ -226,6 +262,7 @@ func (find *ActivityFind) String() string {return string(str)}+// ActivityPatch is the API message for patching an activity.type ActivityPatch struct {ID int `jsonapi:"primary,activityPatch"`@@ -237,6 +274,7 @@ type ActivityPatch struct {Comment *string `jsonapi:"attr,comment"`}+// ActivityDelete is the API message for deleting an activity.type ActivityDelete struct {ID int@@ -245,6 +283,7 @@ type ActivityDelete struct {DeleterID int}+// ActivityService is the service for activities.type ActivityService interface {CreateActivity(ctx context.Context, create *ActivityCreate) (*Activity, error)FindActivityList(ctx context.Context, find *ActivityFind) ([]*Activity, error)diff --git a/api/actuator.go b/api/actuator.goindex 15f956de5d..4067f7ec36 100644--- a/api/actuator.go+++ b/api/actuator.go@@ -1,5 +1,6 @@package api+// ServerInfo is the API message for server info.// Actuator concept is similar to the Spring Boot Actuatortype ServerInfo struct {Version string `json:"version"`diff --git a/api/anomaly.go b/api/anomaly.goindex f74c010be2..a3a6443171 100644--- a/api/anomaly.go+++ b/api/anomaly.go@@ -9,22 +9,33 @@ import (type AnomalyType stringconst (- AnomalyInstanceConnection AnomalyType = "bb.anomaly.instance.connection"- AnomalyInstanceMigrationSchema AnomalyType = "bb.anomaly.instance.migration-schema"+ // AnomalyInstanceConnection is the anomaly type for instance connections.+ AnomalyInstanceConnection AnomalyType = "bb.anomaly.instance.connection"+ // AnomalyInstanceMigrationSchema is the anomaly type for schema migrations.+ AnomalyInstanceMigrationSchema AnomalyType = "bb.anomaly.instance.migration-schema"+ // AnomalyDatabaseBackupPolicyViolation is the anomaly type for backup policy violations.AnomalyDatabaseBackupPolicyViolation AnomalyType = "bb.anomaly.database.backup.policy-violation"- AnomalyDatabaseBackupMissing AnomalyType = "bb.anomaly.database.backup.missing"- AnomalyDatabaseConnection AnomalyType = "bb.anomaly.database.connection"- AnomalyDatabaseSchemaDrift AnomalyType = "bb.anomaly.database.schema.drift"+ // AnomalyDatabaseBackupMissing is the anomaly type for missing backups.+ AnomalyDatabaseBackupMissing AnomalyType = "bb.anomaly.database.backup.missing"+ // AnomalyDatabaseConnection is the anomaly type for database connections.+ AnomalyDatabaseConnection AnomalyType = "bb.anomaly.database.connection"+ // AnomalyDatabaseSchemaDrift is the anomaly type for database schema drifts.+ AnomalyDatabaseSchemaDrift AnomalyType = "bb.anomaly.database.schema.drift")+// AnomalySeverity is the severity of anamoly.type AnomalySeverity stringconst (- AnomalySeverityMedium AnomalySeverity = "MEDIUM"- AnomalySeverityHigh AnomalySeverity = "HIGH"+ // AnomalySeverityMedium is the medium severity.+ AnomalySeverityMedium AnomalySeverity = "MEDIUM"+ // AnomalySeverityHigh is the high severity.+ AnomalySeverityHigh AnomalySeverity = "HIGH"+ // AnomalySeverityCritical is the critical severity.AnomalySeverityCritical AnomalySeverity = "CRITICAL")+// AnomalySeverityFromType maps the severity from a anomaly type.func AnomalySeverityFromType(anomalyType AnomalyType) AnomalySeverity {switch anomalyType {case AnomalyDatabaseBackupPolicyViolation:@@ -40,28 +51,33 @@ func AnomalySeverityFromType(anomalyType AnomalyType) AnomalySeverity {return AnomalySeverityCritical}+// AnomalyInstanceConnectionPayload is the API message for instance connection payloads.type AnomalyInstanceConnectionPayload struct {// Connection failure detailDetail string `json:"detail,omitempty"`}+// AnomalyDatabaseBackupPolicyViolationPayload is the API message for backup policy violation payloads.type AnomalyDatabaseBackupPolicyViolationPayload struct {EnvironmentID int `json:"environmentId,omitempty"`ExpectedBackupSchedule BackupPlanPolicySchedule `json:"expectedSchedule,omitempty"`ActualBackupSchedule BackupPlanPolicySchedule `json:"actualSchedule,omitempty"`}+// AnomalyDatabaseBackupMissingPayload is the API message for missing backup payloads.type AnomalyDatabaseBackupMissingPayload struct {ExpectedBackupSchedule BackupPlanPolicySchedule `json:"expectedSchedule,omitempty"`// Time of last successful backup createdLastBackupTs int64 `json:"lastBackupTs,omitempty"`}+// AnomalyDatabaseConnectionPayload is the API message for database connection payloads.type AnomalyDatabaseConnectionPayload struct {// Connection failure detailDetail string `json:"detail,omitempty"`}+// AnomalyDatabaseSchemaDriftPayload is the API message for database schema drift payloads.type AnomalyDatabaseSchemaDriftPayload struct {// The schema version corresponds to the expected schemaVersion string `json:"version,omitempty"`@@ -71,6 +87,7 @@ type AnomalyDatabaseSchemaDriftPayload struct {Actual string `json:"actual,omitempty"`}+// Anomaly is the API message for an anomaly.type Anomaly struct {ID int `jsonapi:"primary,anomaly"`@@ -94,6 +111,7 @@ type Anomaly struct {Payload string `jsonapi:"attr,payload"`}+// AnomalyUpsert is the API message for creating an anomaly.type AnomalyUpsert struct {// Standard fieldsCreatorID int@@ -107,6 +125,7 @@ type AnomalyUpsert struct {Payload string `jsonapi:"attr,payload"`}+// AnomalyFind is the API message for finding anomalies.type AnomalyFind struct {// Standard fieldsRowStatus *RowStatus@@ -127,12 +146,14 @@ func (find *AnomalyFind) String() string {return string(str)}+// AnomalyArchive is the API message for archiving an anomoly.type AnomalyArchive struct {InstanceID *intDatabaseID *intType AnomalyType}+// AnomalyService is the service for anomaly.type AnomalyService interface {// UpsertActiveAnomaly would update the existing active anomaly if both database id and type match, otherwise create a new one.UpsertActiveAnomaly(ctx context.Context, upsert *AnomalyUpsert) (*Anomaly, error)diff --git a/api/api.go b/api/api.goindex 47d87468df..4f16292dc5 100644--- a/api/api.go+++ b/api/api.go@@ -1,11 +1,15 @@package api-const UNKNOWN_ID = -1+// UnknownID is the ID for unknowns.+const UnknownID = -1+// RowStatus is the status for a row.type RowStatus stringconst (- Normal RowStatus = "NORMAL"+ // Normal is the status for a normal row.+ Normal RowStatus = "NORMAL"+ // Archived is the status for an archived row.Archived RowStatus = "ARCHIVED")diff --git a/api/auth.go b/api/auth.goindex b4e7d6a523..53c71e62f9 100644--- a/api/auth.go+++ b/api/auth.go@@ -1,11 +1,13 @@package api+// Login is the API message for logins.type Login struct {// Domain specific fieldsEmail string `jsonapi:"attr,email"`Password string `jsonapi:"attr,password"`}+// Signup is the API message for sign-ups.type Signup struct {// Domain specific fieldsName string `jsonapi:"attr,name"`diff --git a/api/backup.go b/api/backup.goindex aff43606c4..9e9f6c0c55 100644--- a/api/backup.go+++ b/api/backup.go@@ -66,6 +66,7 @@ func (e BackupStorageBackend) String() string {return "UNKNOWN"}+// Backup is the API message for a backup.type Backup struct {ID int `jsonapi:"primary,backup"`@@ -92,6 +93,7 @@ type Backup struct {Comment string `jsonapi:"attr,comment"`}+// BackupCreate is the API message for creating a backup.type BackupCreate struct {// Standard fields// Value is assigned from the jwt subject field passed by the client.@@ -109,6 +111,7 @@ type BackupCreate struct {Path string `jsonapi:"attr,path"`}+// BackupFind is the API message for finding backups.type BackupFind struct {ID *int@@ -128,6 +131,7 @@ func (find *BackupFind) String() string {return string(str)}+// BackupPatch is the API message for patching a backup.type BackupPatch struct {ID int@@ -201,7 +205,7 @@ type BackupSettingsMatch struct {DayOfWeek int}-// BackupService is the backend for backups.+// BackupService is the service for backups.type BackupService interface {CreateBackup(ctx context.Context, create *BackupCreate) (*Backup, error)FindBackup(ctx context.Context, find *BackupFind) (*Backup, error)diff --git a/api/bookmark.go b/api/bookmark.goindex b93dccd4f0..f0ffad7fae 100644--- a/api/bookmark.go+++ b/api/bookmark.go@@ -5,6 +5,7 @@ import ("encoding/json")+// Bookmark is the API message for a bookmark.type Bookmark struct {ID int `jsonapi:"primary,bookmark"`@@ -21,6 +22,7 @@ type Bookmark struct {Link string `jsonapi:"attr,link"`}+// BookmarkCreate is the API message for creating a bookmark.type BookmarkCreate struct {// Standard fields// Value is assigned from the jwt subject field passed by the client.@@ -31,6 +33,7 @@ type BookmarkCreate struct {Link string `jsonapi:"attr,link"`}+// BookmarkFind is the API message for finding bookmarks.type BookmarkFind struct {ID *int@@ -46,6 +49,7 @@ func (find *BookmarkFind) String() string {return string(str)}+// BookmarkDelete is the API message for deleting a bookmark.type BookmarkDelete struct {ID int@@ -54,6 +58,7 @@ type BookmarkDelete struct {DeleterID int}+// BookmarkService is the service for bookmarks.type BookmarkService interface {CreateBookmark(ctx context.Context, create *BookmarkCreate) (*Bookmark, error)FindBookmarkList(ctx context.Context, find *BookmarkFind) ([]*Bookmark, error)diff --git a/api/cache.go b/api/cache.goindex 5d9ef26955..aad58f419b 100644--- a/api/cache.go+++ b/api/cache.go@@ -1,18 +1,28 @@package api+// CacheNamespace is the type of a cache.type CacheNamespace stringconst (- PrincipalCache CacheNamespace = "p"+ // PrincipalCache is the cache type of principals.+ PrincipalCache CacheNamespace = "p"+ // EnvironmentCache is the cache type of environments.EnvironmentCache CacheNamespace = "e"- ProjectCache CacheNamespace = "r"- InstanceCache CacheNamespace = "i"- DatabaseCache CacheNamespace = "d"- MemberCache CacheNamespace = "m"- PipelineCache CacheNamespace = "pl"- IssueCache CacheNamespace = "is"+ // ProjectCache is the cache type of projects.+ ProjectCache CacheNamespace = "r"+ // InstanceCache is the cache type of instances.+ InstanceCache CacheNamespace = "i"+ // DatabaseCache is the cache type of databases.+ DatabaseCache CacheNamespace = "d"+ // MemberCache is the cache type of members.+ MemberCache CacheNamespace = "m"+ // PipelineCache is the cache type of pipelines.+ PipelineCache CacheNamespace = "pl"+ // IssueCache is the cache type of issues.+ IssueCache CacheNamespace = "is")+// CacheService is the service for caches.type CacheService interface {FindCache(namespace CacheNamespace, id int, entry interface{}) (bool, error)UpsertCache(namespace CacheNamespace, id int, entry interface{}) errordiff --git a/api/column.go b/api/column.goindex 115a4570aa..184a47f719 100644--- a/api/column.go+++ b/api/column.go@@ -5,6 +5,7 @@ import ("encoding/json")+// Column is the API message for a table column.type Column struct {ID int `jsonapi:"primary,column"`@@ -29,6 +30,7 @@ type Column struct {Comment string `json:"comment"`}+// ColumnCreate is the API message for creating a column.type ColumnCreate struct {// Standard fields// Value is assigned from the jwt subject field passed by the client.@@ -49,6 +51,7 @@ type ColumnCreate struct {Comment string}+// ColumnFind is the API message for finding columns.type ColumnFind struct {ID *int@@ -68,6 +71,7 @@ func (find *ColumnFind) String() string {return string(str)}+// ColumnPatch is the API message for patching a columns.type ColumnPatch struct {ID int@@ -76,6 +80,7 @@ type ColumnPatch struct {UpdaterID int}+// ColumnService is the service for columns.type ColumnService interface {CreateColumn(ctx context.Context, create *ColumnCreate) (*Column, error)FindColumnList(ctx context.Context, find *ColumnFind) ([]*Column, error)diff --git a/api/data_source.go b/api/data_source.goindex 44115ae284..ff81b59be3 100644--- a/api/data_source.go+++ b/api/data_source.go@@ -7,15 +7,20 @@ import ()const (- ADMIN_DATA_SOURCE_NAME = "Admin data source"+ // AdminDataSourceName is the name for administrative data source.+ AdminDataSourceName = "Admin data source")+// DataSourceType is the type of data source.type DataSourceType stringconst (+ // Admin is the ADMIN type of data source.Admin DataSourceType = "ADMIN"- RW DataSourceType = "RW"- RO DataSourceType = "RO"+ // RW is the read/write type of data source.+ RW DataSourceType = "RW"+ // RO is the read-only type of data source.+ RO DataSourceType = "RO")func (e DataSourceType) String() string {@@ -30,6 +35,7 @@ func (e DataSourceType) String() string {return ""}+// DataSource is the API message for a data source.type DataSource struct {ID int `jsonapi:"primary,dataSource"`@@ -53,6 +59,7 @@ type DataSource struct {Password string `jsonapi:"attr,password"`}+// DataSourceCreate is the API message for creating a data source.type DataSourceCreate struct {// Standard fields// Value is assigned from the jwt subject field passed by the client.@@ -69,6 +76,7 @@ type DataSourceCreate struct {Password string `jsonapi:"attr,password"`}+// DataSourceFind is the API message for finding data sources.type DataSourceFind struct {// Related fieldsInstanceID *int@@ -86,6 +94,7 @@ func (find *DataSourceFind) String() string {return string(str)}+// DataSourcePatch is the API message for data source.type DataSourcePatch struct {ID int `jsonapi:"primary,dataSourcePatch"`@@ -98,6 +107,7 @@ type DataSourcePatch struct {Password *string `jsonapi:"attr,password"`}+// DataSourceService is the service for data source.type DataSourceService interface {CreateDataSource(ctx context.Context, create *DataSourceCreate) (*DataSource, error)// This is specifically used to create the admin data source when creating the instance.diff --git a/api/database.go b/api/database.goindex 3d54ea9bf9..ecf819253a 100644--- a/api/database.go+++ b/api/database.go@@ -7,17 +7,23 @@ import ()const (- ALL_DATABASE_NAME = "*"- DEFAULT_CHARACTER_SET_NAME = "utf8mb4"+ // AllDatabaseName is the wild expression for all databases.+ AllDatabaseName = "*"+ // DefaultCharactorSetName is the default charactor set.+ DefaultCharactorSetName = "utf8mb4"+ // DefaultCollationName is the default collation name.// Use utf8mb4_general_ci instead of the new MySQL 8.0.1 default utf8mb4_0900_ai_ci// because the former is compatible with more other MySQL flavors (e.g. MariaDB)- DEFAULT_COLLATION_NAME = "utf8mb4_general_ci"+ DefaultCollationName = "utf8mb4_general_ci")+// SyncStatus is the database sync status.type SyncStatus stringconst (- OK SyncStatus = "OK"+ // OK is the OK sync status.+ OK SyncStatus = "OK"+ // NotFound is the NOT_FOUND sync status.NotFound SyncStatus = "NOT_FOUND")@@ -31,6 +37,7 @@ func (e SyncStatus) String() string {return ""}+// Database is the API message for a database.type Database struct {ID int `jsonapi:"primary,database"`@@ -61,6 +68,7 @@ type Database struct {LastSuccessfulSyncTs int64 `jsonapi:"attr,lastSuccessfulSyncTs"`}+// DatabaseCreate is the API message for creating a database.type DatabaseCreate struct {// Standard fields// Value is assigned from the jwt subject field passed by the client.@@ -78,6 +86,7 @@ type DatabaseCreate struct {IssueID int `jsonapi:"attr,issueId"`}+// DatabaseFind is the API message for finding databases.type DatabaseFind struct {ID *int@@ -98,6 +107,7 @@ func (find *DatabaseFind) String() string {return string(str)}+// DatabasePatch is the API message for patching a database.type DatabasePatch struct {ID int@@ -114,6 +124,7 @@ type DatabasePatch struct {LastSuccessfulSyncTs *int64}+// DatabaseService is the service for databases.type DatabaseService interface {CreateDatabase(ctx context.Context, create *DatabaseCreate) (*Database, error)// This is specifically used to create the * database when creating the instance.diff --git a/server/activity.go b/server/activity.goindex 38f64a3d84..3649151059 100644--- a/server/activity.go+++ b/server/activity.go@@ -21,7 +21,7 @@ func (s *Server) registerActivityRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusBadRequest, "Malformatted create activity request").SetInternal(err)}- activityCreate.Level = api.ACTIVITY_INFO+ activityCreate.Level = api.ActivityInfoactivityCreate.CreatorID = c.Get(GetPrincipalIDContextKey()).(int)var foundIssue *api.Issueif activityCreate.Type == api.ActivityIssueCommentCreate {diff --git a/server/auth.go b/server/auth.goindex a4045fefcb..53727f05da 100644--- a/server/auth.go+++ b/server/auth.go@@ -146,7 +146,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {CreatorID: user.ID,ContainerID: member.ID,Type: api.ActivityMemberCreate,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Payload: string(bytes),}_, err = s.ActivityManager.CreateActivity(ctx, activityCreate, &ActivityMeta{})diff --git a/server/database.go b/server/database.goindex a688da1082..1512b0d324 100644--- a/server/database.go+++ b/server/database.go@@ -185,7 +185,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {CreatorID: c.Get(GetPrincipalIDContextKey()).(int),ContainerID: existingDatabase.ProjectID,Type: api.ActivityProjectDatabaseTransfer,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Comment: fmt.Sprintf("Transferred out database %q to project %q.",database.Name, database.Project.Name),Payload: string(bytes),@@ -207,7 +207,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {CreatorID: c.Get(GetPrincipalIDContextKey()).(int),ContainerID: database.ProjectID,Type: api.ActivityProjectDatabaseTransfer,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Comment: fmt.Sprintf("Transferred in database %q from project %q.",existingDatabase.Name, existingDatabase.Project.Name),Payload: string(bytes),@@ -586,7 +586,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {if common.ErrorCode(err) == common.NotFound {// Returns the backup setting with UNKNOWN_ID to indicate the database has no backupbackupSetting = &api.BackupSetting{- ID: api.UNKNOWN_ID,+ ID: api.UnknownID,}} else {return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to get backup setting for database id: %d", id)).SetInternal(err)diff --git a/server/issue.go b/server/issue.goindex b227247704..b188141147 100644--- a/server/issue.go+++ b/server/issue.go@@ -27,7 +27,7 @@ func (s *Server) registerIssueRoutes(g *echo.Group) {// since we are not creating pipeline/stage list/task list in a single transaction.// We may still run into this issue when we actually create those pipeline/stage list/task list, however, that's// quite unlikely so we will live with it for now.- if issueCreate.AssigneeID == api.UNKNOWN_ID {+ if issueCreate.AssigneeID == api.UnknownID {return echo.NewHTTPError(http.StatusBadRequest, "Failed to create issue, assignee missing")}@@ -270,7 +270,7 @@ func (s *Server) registerIssueRoutes(g *echo.Group) {CreatorID: c.Get(GetPrincipalIDContextKey()).(int),ContainerID: issue.ID,Type: api.ActivityIssueFieldUpdate,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Payload: string(payload),}_, err := s.ActivityManager.CreateActivity(ctx, activityCreate, &ActivityMeta{@@ -510,7 +510,7 @@ func (s *Server) CreateIssue(ctx context.Context, issueCreate *api.IssueCreate,CreatorID: creatorID,ContainerID: issue.ID,Type: api.ActivityIssueCreate,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Payload: string(bytes),}_, err = s.ActivityManager.CreateActivity(ctx, activityCreate, &ActivityMeta{@@ -539,7 +539,7 @@ func (s *Server) CreateIssue(ctx context.Context, issueCreate *api.IssueCreate,CreatorID: creatorID,ContainerID: *issueCreate.RollbackIssueID,Type: api.ActivityIssueCommentCreate,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Comment: fmt.Sprintf("Created rollback issue %q", issue.Name),Payload: string(bytes),}@@ -628,7 +628,7 @@ func (s *Server) ChangeIssueStatus(ctx context.Context, issue *api.Issue, newStaCreatorID: updaterID,ContainerID: issue.ID,Type: api.ActivityIssueStatusUpdate,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Comment: comment,Payload: string(payload),}diff --git a/server/member.go b/server/member.goindex 390179b9ed..ba133774a3 100644--- a/server/member.go+++ b/server/member.go@@ -58,7 +58,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {CreatorID: c.Get(GetPrincipalIDContextKey()).(int),ContainerID: member.ID,Type: api.ActivityMemberCreate,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Payload: string(bytes),}_, err = s.ActivityManager.CreateActivity(ctx, activityCreate, &ActivityMeta{})@@ -161,7 +161,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {CreatorID: c.Get(GetPrincipalIDContextKey()).(int),ContainerID: updatedMember.ID,Type: api.ActivityMemberRoleUpdate,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Payload: string(bytes),}_, err = s.ActivityManager.CreateActivity(ctx, activityCreate, &ActivityMeta{})@@ -186,7 +186,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {CreatorID: c.Get(GetPrincipalIDContextKey()).(int),ContainerID: updatedMember.ID,Type: theType,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Payload: string(bytes),}_, err = s.ActivityManager.CreateActivity(ctx, activityCreate, &ActivityMeta{})diff --git a/server/project_member.go b/server/project_member.goindex 1b84b3626b..cbb2739dd8 100644--- a/server/project_member.go+++ b/server/project_member.go@@ -46,7 +46,7 @@ func (s *Server) registerProjectMemberRoutes(g *echo.Group) {CreatorID: c.Get(GetPrincipalIDContextKey()).(int),ContainerID: projectID,Type: api.ActivityProjectMemberCreate,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Comment: fmt.Sprintf("Granted %s to %s (%s).",projectMember.Principal.Name, projectMember.Principal.Email, projectMember.Role),}@@ -113,7 +113,7 @@ func (s *Server) registerProjectMemberRoutes(g *echo.Group) {CreatorID: c.Get(GetPrincipalIDContextKey()).(int),ContainerID: projectID,Type: api.ActivityProjectMemberRoleUpdate,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Comment: fmt.Sprintf("Changed %s (%s) from %s to %s.",projectMember.Principal.Name, projectMember.Principal.Email, existingProjectMember.Role, projectMember.Role),}@@ -175,7 +175,7 @@ func (s *Server) registerProjectMemberRoutes(g *echo.Group) {CreatorID: c.Get(GetPrincipalIDContextKey()).(int),ContainerID: projectID,Type: api.ActivityProjectMemberDelete,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Comment: fmt.Sprintf("Revoked %s from %s (%s).",projectMember.Role, projectMember.Principal.Name, projectMember.Principal.Email),}diff --git a/server/task.go b/server/task.goindex 6125701f8d..c20fcbf9de 100644--- a/server/task.go+++ b/server/task.go@@ -384,9 +384,9 @@ func (s *Server) ChangeTaskStatusWithPatch(ctx context.Context, task *api.Task,if issue != nil {containerID = issue.ID}- level := api.ACTIVITY_INFO+ level := api.ActivityInfoif updatedTask.Status == api.TaskFailed {- level = api.ACTIVITY_ERROR+ level = api.ActivityError}activityCreate := &api.ActivityCreate{CreatorID: taskStatusPatch.UpdaterID,diff --git a/server/task_executor_schema_update.go b/server/task_executor_schema_update.goindex 9002017d34..195b5df279 100644--- a/server/task_executor_schema_update.go+++ b/server/task_executor_schema_update.go@@ -206,7 +206,7 @@ func (exec *SchemaUpdateTaskExecutor) RunOnce(ctx context.Context, server *ServeCreatorID: task.CreatorID,ContainerID: containerID,Type: api.ActivityPipelineTaskFileCommit,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Comment: fmt.Sprintf("Committed the latest schema after applying migration version %s to %q.",mi.Version,mi.Database,diff --git a/server/webhook.go b/server/webhook.goindex 7f454e4c9a..44f269c17f 100644--- a/server/webhook.go+++ b/server/webhook.go@@ -137,7 +137,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {CreatorID: api.SYSTEM_BOT_ID,ContainerID: repository.ProjectID,Type: api.ActivityProjectRepositoryPush,- Level: api.ACTIVITY_WARN,+ Level: api.ActivityWarn,Comment: fmt.Sprintf("Ignored committed file %q, %s.", added, err.Error()),Payload: string(bytes),}@@ -316,7 +316,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {CreatorID: api.SYSTEM_BOT_ID,ContainerID: repository.ProjectID,Type: api.ActivityProjectRepositoryPush,- Level: api.ACTIVITY_INFO,+ Level: api.ActivityInfo,Comment: fmt.Sprintf("Created issue %q.", issue.Name),Payload: string(bytes),}diff --git a/store/database.go b/store/database.goindex 7d90057a8b..e5e940dcdf 100644--- a/store/database.go+++ b/store/database.go@@ -251,7 +251,7 @@ func (s *DatabaseService) findDatabaseList(ctx context.Context, tx *Tx, find *apwhere, args = append(where, "name = ?"), append(args, *v)}if !find.IncludeAllDatabase {- where = append(where, "name != '"+api.ALL_DATABASE_NAME+"'")+ where = append(where, "name != '"+api.AllDatabaseName+"'")}rows, err := tx.QueryContext(ctx, `diff --git a/store/instance.go b/store/instance.goindex 37ab9fc6fa..13e41c1058 100644--- a/store/instance.go+++ b/store/instance.go@@ -49,9 +49,9 @@ func (s *InstanceService) CreateInstance(ctx context.Context, create *api.InstanProjectID: api.DEFAULT_PROJECT_ID,InstanceID: instance.ID,EnvironmentID: instance.EnvironmentID,- Name: api.ALL_DATABASE_NAME,- CharacterSet: api.DEFAULT_CHARACTER_SET_NAME,- Collation: api.DEFAULT_COLLATION_NAME,+ Name: api.AllDatabaseName,+ CharacterSet: api.DefaultCharactorSetName,+ Collation: api.DefaultCollationName,}allDatabase, err := s.databaseService.CreateDatabaseTx(ctx, tx.Tx, databaseCreate)if err != nil {@@ -63,7 +63,7 @@ func (s *InstanceService) CreateInstance(ctx context.Context, create *api.InstanCreatorID: create.CreatorID,InstanceID: instance.ID,DatabaseID: allDatabase.ID,- Name: api.ADMIN_DATA_SOURCE_NAME,+ Name: api.AdminDataSourceName,Type: api.Admin,Username: create.Username,Password: create.Password,