Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Some backup related coding style change to make it consistent with other code
天舟7b7bb879de50
diff --git a/api/backup.go b/api/backup.goindex 1b3a89f04b..963037a8b2 100644--- a/api/backup.go+++ b/api/backup.go@@ -8,12 +8,6 @@ import (// BackupStatus is the status of a backup.type BackupStatus string-// BackupType is the type of a backup.-type BackupType string--// BackupStorageBackend is the storage backend of a backup.-type BackupStorageBackend string-const (// BackupStatusPendingCreate is the status for PENDING_CREATE.BackupStatusPendingCreate BackupStatus = "PENDING_CREATE"@@ -21,14 +15,56 @@ const (BackupStatusDone BackupStatus = "DONE"// BackupStatusFailed is the status for FAILED.BackupStatusFailed BackupStatus = "FAILED"+)++func (e BackupStatus) String() string {+ switch e {+ case BackupStatusPendingCreate:+ return "PENDING_CREATE"+ case BackupStatusDone:+ return "DONE"+ case BackupStatusFailed:+ return "FAILED"+ }+ return "UNKNOWN"+}++// BackupType is the type of a backup.+type BackupType string++const (// BackupTypeAutomatic is the type for automatic backup.BackupTypeAutomatic BackupType = "AUTOMATIC"// BackupTypeManual is the type for manual backup.BackupTypeManual BackupType = "MANUAL"+)++func (e BackupType) String() string {+ switch e {+ case BackupTypeAutomatic:+ return "AUTOMATIC"+ case BackupTypeManual:+ return "MANUAL"+ }+ return "UNKNOWN"+}++// BackupStorageBackend is the storage backend of a backup.+type BackupStorageBackend string++const (// BackupStorageBackendLocal is the local storage backend for a backup.BackupStorageBackendLocal BackupStorageBackend = "LOCAL")+func (e BackupStorageBackend) String() string {+ switch e {+ case BackupStorageBackendLocal:+ return "LOCAL"+ }+ return "UNKNOWN"+}+type Backup struct {ID int `jsonapi:"primary,backup"`@@ -107,7 +143,7 @@ type RestoreBackup struct {// Related fields// Domain specific fields- BackupID int `jsonapi:"attr,backupId"`+ BackupId int `jsonapi:"attr,backupId"`}// BackupSetting is the backup setting for a database.diff --git a/server/database.go b/server/database.goindex 8c5467b20b..cd8c909cf0 100644--- a/server/database.go+++ b/server/database.go@@ -405,7 +405,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {}backupFind := &api.BackupFind{DatabaseId: &id,- ID: &restoreBackup.BackupID,+ ID: &restoreBackup.BackupId,}backup, err := s.BackupService.FindBackup(context.Background(), backupFind)if err != nil {diff --git a/store/backup.go b/store/backup.goindex 2cd511aed7..ab902157f3 100644--- a/store/backup.go+++ b/store/backup.go@@ -306,13 +306,13 @@ func (s *BackupService) getBackupSetting(ctx context.Context, tx *Tx, get *api.Brows, err := tx.QueryContext(ctx, `SELECT- id,- creator_id,- created_ts,- updater_id,- updated_ts,+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,database_id,- enabled,+ enabled,hour,day_of_week,path_template@@ -388,12 +388,12 @@ func (s *BackupService) setBackupSetting(ctx context.Context, tx *Tx, setting *a)VALUES (?, ?, ?, ?, ?, ?, ?)ON CONFLICT(database_id) DO UPDATE SET- enabled=excluded.enabled,- hour=excluded.hour,- day_of_week=excluded.day_of_week,- path=excluded.path- RETURNING id, creator_id, created_ts, updater_id, updated_ts, database_id, `+"`enabled`,"+` `+"hour, day_of_week, path_template"+`- `,+ enabled = excluded.enabled,+ hour = excluded.hour,+ day_of_week = excluded.day_of_week,+ path = excluded.path+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, database_id, `+"`enabled`,"+` `+"hour, day_of_week, path_template"+`+ `,setting.CreatorId,setting.CreatorId,setting.DatabaseId,@@ -438,13 +438,13 @@ func (s *BackupService) GetBackupSettingsMatch(ctx context.Context, match *api.Brows, err := tx.QueryContext(ctx, `SELECT- id,- creator_id,- created_ts,- updater_id,- updated_ts,+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,database_id,- enabled,+ enabled,hour,day_of_week,path_template