Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Add hook_url field to backup setting (#38)
p0nyb689758bf947
diff --git a/api/backup.go b/api/backup.goindex be376b04d9..01292246e2 100644--- a/api/backup.go+++ b/api/backup.go@@ -162,6 +162,8 @@ type BackupSetting struct {Enabled bool `jsonapi:"attr,enabled"`Hour int `jsonapi:"attr,hour"`DayOfWeek int `jsonapi:"attr,dayOfWeek"`+ // HookURL is the callback url to be requested (using HTTP GET) after a successful backup.+ HookURL string `jsonapi:"attr,hook_url"`}// BackupSettingFind is the message to get a backup settings.@@ -187,9 +189,10 @@ type BackupSettingUpsert struct {EnvironmentId int// Domain specific fields- Enabled bool `jsonapi:"attr,enabled"`- Hour int `jsonapi:"attr,hour"`- DayOfWeek int `jsonapi:"attr,dayOfWeek"`+ Enabled bool `jsonapi:"attr,enabled"`+ Hour int `jsonapi:"attr,hour"`+ DayOfWeek int `jsonapi:"attr,dayOfWeek"`+ HookURL string `jsonapi:"attr,hook_url"`}// BackupSettingsMatch is the message to find backup settings matching the conditions.diff --git a/frontend/src/types/backup.ts b/frontend/src/types/backup.tsindex bb2f066ee1..7065cac278 100644--- a/frontend/src/types/backup.ts+++ b/frontend/src/types/backup.ts@@ -56,6 +56,7 @@ export type BackupSetting = {enabled: boolean;hour: number;dayOfWeek: number;+ hookURL: string;};export type BackupSettingUpsert = {@@ -66,4 +67,5 @@ export type BackupSettingUpsert = {enabled: boolean;hour: number;dayOfWeek: number;+ hookURL: string;};diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex 9981d4f7ec..5664ecb572 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -278,6 +278,7 @@ export const unknown = (enabled: false,hour: 0,dayOfWeek: 0,+ hookURL: "",};const UNKNOWN_PIPELINE: Pipeline = {@@ -628,6 +629,7 @@ export const empty = (enabled: false,hour: 0,dayOfWeek: 0,+ hookURL: "",};const EMPTY_PIPELINE: Pipeline = {diff --git a/store/backup.go b/store/backup.goindex ae9f874278..dc61d02d20 100644--- a/store/backup.go+++ b/store/backup.go@@ -324,7 +324,8 @@ func (s *BackupService) findBackupSetting(ctx context.Context, tx *Tx, find *apidatabase_id,enabled,hour,- day_of_week+ day_of_week,+ hook_urlFROM backup_settingWHERE `+strings.Join(where, " AND "),args...,@@ -348,6 +349,7 @@ func (s *BackupService) findBackupSetting(ctx context.Context, tx *Tx, find *api&backupSetting.Enabled,&backupSetting.Hour,&backupSetting.DayOfWeek,+ &backupSetting.HookURL,); err != nil {return nil, FormatError(err)}@@ -412,14 +414,16 @@ func (s *BackupService) UpsertBackupSettingTx(ctx context.Context, tx *sql.Tx, udatabase_id,`+"`enabled`,"+`hour,- day_of_week+ day_of_week,+ hook_url)- VALUES (?, ?, ?, ?, ?, ?)+ VALUES (?, ?, ?, ?, ?, ?, ?)ON CONFLICT(database_id) DO UPDATE SETenabled = excluded.enabled,hour = excluded.hour,day_of_week = excluded.day_of_week- RETURNING id, creator_id, created_ts, updater_id, updated_ts, database_id, `+"`enabled`,"+` `+"hour, day_of_week"+`+ hook_url = excluded.hook_url+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, database_id, `+"`enabled`,"+` `+"hour, day_of_week"+`, hook_url`,upsert.UpdaterId,upsert.UpdaterId,@@ -427,6 +431,7 @@ func (s *BackupService) UpsertBackupSettingTx(ctx context.Context, tx *sql.Tx, uupsert.Enabled,upsert.Hour,upsert.DayOfWeek,+ upsert.HookURL,)if err != nil {@@ -446,6 +451,7 @@ func (s *BackupService) UpsertBackupSettingTx(ctx context.Context, tx *sql.Tx, u&backupSetting.Enabled,&backupSetting.Hour,&backupSetting.DayOfWeek,+ &backupSetting.HookURL,); err != nil {return nil, FormatError(err)}@@ -471,7 +477,8 @@ func (s *BackupService) FindBackupSettingsMatch(ctx context.Context, match *api.database_id,enabled,hour,- day_of_week+ day_of_week,+ hook_urlFROM backup_settingWHEREenabled = 1@@ -504,6 +511,7 @@ func (s *BackupService) FindBackupSettingsMatch(ctx context.Context, match *api.&backupSetting.Enabled,&backupSetting.Hour,&backupSetting.DayOfWeek,+ &backupSetting.HookURL,); err != nil {return nil, FormatError(err)}diff --git a/store/database.go b/store/database.goindex 96827301ea..308d6fbbd7 100644--- a/store/database.go+++ b/store/database.go@@ -75,6 +75,7 @@ func (s *DatabaseService) CreateDatabaseTx(ctx context.Context, tx *sql.Tx, creaDatabaseId: database.ID,Enabled: true,Hour: rand.Intn(24),+ HookURL: "",}switch backupPlanPolicy.Schedule {case api.BackupPlanPolicyScheduleDaily:diff --git a/store/migration/10001__init_schema.sql b/store/migration/10001__init_schema.sqlindex 11e9cce05b..91a938e5b3 100644--- a/store/migration/10001__init_schema.sql+++ b/store/migration/10001__init_schema.sql@@ -716,7 +716,9 @@ CREATE TABLE backup_setting (day_of_week INTEGER NOT NULL CHECK (-1 <= day_of_weekAND day_of_week < 7- )+ ),+ -- hook_url is the callback url to be requested after a successful backup.+ hook_url TEXT NOT NULL);CREATE INDEX idx_backup_setting_database_id ON backup_setting(database_id);