Skip to content

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

Returns backup list in created_ts descending order and allow find list by status

天舟5d890d4fcbbe
diff --git a/api/backup.go b/api/backup.go
index 1ce0814138..025e5eb093 100644
--- a/api/backup.go
+++ b/api/backup.go
@@ -116,7 +116,8 @@ type BackupFind struct {
DatabaseId *int
// Domain specific fields
- Name *string
+ Name *string
+ Status *BackupStatus
}
func (find *BackupFind) String() string {
@@ -201,6 +202,7 @@ type BackupSettingsMatch struct {
type BackupService interface {
CreateBackup(ctx context.Context, create *BackupCreate) (*Backup, error)
FindBackup(ctx context.Context, find *BackupFind) (*Backup, error)
+ // Returns backup list in created_ts descending order.
FindBackupList(ctx context.Context, find *BackupFind) ([]*Backup, error)
PatchBackup(ctx context.Context, patch *BackupPatch) (*Backup, error)
FindBackupSetting(ctx context.Context, find *BackupSettingFind) (*BackupSetting, error)
diff --git a/store/backup.go b/store/backup.go
index d46eece616..cc013ed448 100644
--- a/store/backup.go
+++ b/store/backup.go
@@ -175,6 +175,9 @@ func (s *BackupService) findBackupList(ctx context.Context, tx *Tx, find *api.Ba
if v := find.Name; v != nil {
where, args = append(where, "name = ?"), append(args, *v)
}
+ if v := find.Status; v != nil {
+ where, args = append(where, "`status` = ?"), append(args, *v)
+ }
rows, err := tx.QueryContext(ctx, `
SELECT
@@ -192,7 +195,7 @@ func (s *BackupService) findBackupList(ctx context.Context, tx *Tx, find *api.Ba
path,
comment
FROM backup
- WHERE `+strings.Join(where, " AND "),
+ WHERE `+strings.Join(where, " AND ")+` ORDER BY created_ts DESC`,
args...,
)
if err != nil {