Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Rename backup_setting table "path" column to "path_template"

天舟e01054e22341
diff --git a/api/backup.go b/api/backup.go
index 9da391d9ff..1b3a89f04b 100644
--- a/api/backup.go
+++ b/api/backup.go
@@ -127,10 +127,10 @@ type BackupSetting struct {
Database *Database `jsonapi:"relation,database"`
// Domain specific fields
- Enabled bool `jsonapi:"attr,enabled"`
- Hour int `jsonapi:"attr,hour"`
- DayOfWeek int `jsonapi:"attr,dayOfWeek"`
- Path string `jsonapi:"attr,path"`
+ Enabled bool `jsonapi:"attr,enabled"`
+ Hour int `jsonapi:"attr,hour"`
+ DayOfWeek int `jsonapi:"attr,dayOfWeek"`
+ PathTemplate string `jsonapi:"attr,pathTemplate"`
}
// BackupSettingGet is the message to get a backup settings.
@@ -154,10 +154,10 @@ type BackupSettingSet struct {
DatabaseId int `jsonapi:"attr,databaseId"`
// Domain specific fields
- Enabled bool `jsonapi:"attr,enabled"`
- Hour int `jsonapi:"attr,hour"`
- DayOfWeek int `jsonapi:"attr,dayOfWeek"`
- Path string `jsonapi:"attr,path"`
+ Enabled bool `jsonapi:"attr,enabled"`
+ Hour int `jsonapi:"attr,hour"`
+ DayOfWeek int `jsonapi:"attr,dayOfWeek"`
+ PathTemplate string `jsonapi:"attr,pathTemplate"`
}
// BackupSettingsMatch is the message to find backup settings matching the conditions.
diff --git a/frontend/src/types/backup.ts b/frontend/src/types/backup.ts
index 767884d190..49bb02b1ec 100644
--- a/frontend/src/types/backup.ts
+++ b/frontend/src/types/backup.ts
@@ -59,7 +59,7 @@ export type BackupSetting = {
enabled: boolean;
hour: number;
dayOfWeek: number;
- path: string;
+ pathTemplate: string;
};
export type BackupSettingSet = {
@@ -70,5 +70,5 @@ export type BackupSettingSet = {
enabled: boolean;
hour: number;
dayOfWeek: number;
- path: string;
+ pathTemplate: string;
};
diff --git a/server/backup_runner.go b/server/backup_runner.go
index c065a3beb4..5bc59c495a 100644
--- a/server/backup_runner.go
+++ b/server/backup_runner.go
@@ -91,8 +91,8 @@ func (s *BackupRunner) Run() error {
func (s *BackupRunner) scheduleBackupTask(backupSetting *api.BackupSetting, uniqueKey string, epoch int64) error {
key := fmt.Sprintf("auto-backup-%s-%v", uniqueKey, backupSetting.DatabaseId)
path := fmt.Sprintf("%s-%s-%v.sql", backupSetting.Database.Instance.Environment.Name, backupSetting.Database.Name, epoch)
- if backupSetting.Path != "" {
- path = strings.ReplaceAll(backupSetting.Path, "{{TIME}}", fmt.Sprintf("%v", epoch))
+ if backupSetting.PathTemplate != "" {
+ path = strings.ReplaceAll(backupSetting.PathTemplate, "{{TIME}}", fmt.Sprintf("%v", epoch))
}
backupCreate := &api.BackupCreate{
CreatorId: api.SYSTEM_BOT_ID,
diff --git a/store/backup.go b/store/backup.go
index b3d6e93d37..2cd511aed7 100644
--- a/store/backup.go
+++ b/store/backup.go
@@ -315,7 +315,7 @@ func (s *BackupService) getBackupSetting(ctx context.Context, tx *Tx, get *api.B
enabled,
hour,
day_of_week,
- path
+ path_template
FROM backup_setting
WHERE `+strings.Join(where, " AND "),
args...,
@@ -339,7 +339,7 @@ func (s *BackupService) getBackupSetting(ctx context.Context, tx *Tx, get *api.B
&backupSetting.Enabled,
&backupSetting.Hour,
&backupSetting.DayOfWeek,
- &backupSetting.Path,
+ &backupSetting.PathTemplate,
); err != nil {
return nil, FormatError(err)
}
@@ -384,7 +384,7 @@ func (s *BackupService) setBackupSetting(ctx context.Context, tx *Tx, setting *a
`+"`enabled`,"+`
hour,
day_of_week,
- path
+ path_template
)
VALUES (?, ?, ?, ?, ?, ?, ?)
ON CONFLICT(database_id) DO UPDATE SET
@@ -392,7 +392,7 @@ func (s *BackupService) setBackupSetting(ctx context.Context, tx *Tx, setting *a
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"+`
+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, database_id, `+"`enabled`,"+` `+"hour, day_of_week, path_template"+`
`,
setting.CreatorId,
setting.CreatorId,
@@ -400,7 +400,7 @@ func (s *BackupService) setBackupSetting(ctx context.Context, tx *Tx, setting *a
setting.Enabled,
setting.Hour,
setting.DayOfWeek,
- setting.Path,
+ setting.PathTemplate,
)
if err != nil {
@@ -420,7 +420,7 @@ func (s *BackupService) setBackupSetting(ctx context.Context, tx *Tx, setting *a
&backupSetting.Enabled,
&backupSetting.Hour,
&backupSetting.DayOfWeek,
- &backupSetting.Path,
+ &backupSetting.PathTemplate,
); err != nil {
return nil, FormatError(err)
}
@@ -447,7 +447,7 @@ func (s *BackupService) GetBackupSettingsMatch(ctx context.Context, match *api.B
enabled,
hour,
day_of_week,
- path
+ path_template
FROM backup_setting
WHERE
enabled = 1
@@ -480,7 +480,7 @@ func (s *BackupService) GetBackupSettingsMatch(ctx context.Context, match *api.B
&backupSetting.Enabled,
&backupSetting.Hour,
&backupSetting.DayOfWeek,
- &backupSetting.Path,
+ &backupSetting.PathTemplate,
); err != nil {
return nil, FormatError(err)
}
diff --git a/store/migration/10001__init_schema.sql b/store/migration/10001__init_schema.sql
index ba3b061bef..5303c5810b 100644
--- a/store/migration/10001__init_schema.sql
+++ b/store/migration/10001__init_schema.sql
@@ -653,7 +653,7 @@ CREATE TABLE backup_setting (
-1 <= day_of_week
AND day_of_week < 7
),
- path TEXT
+ path_template TEXT NOT NULL
);
CREATE INDEX idx_backup_setting_database_id ON backup_setting(database_id);