fix(restore): reject backups from a mismatching schema version
Backup payloads carry the source SchemaVersion but Restore ignored it, silently importing data shaped for a different schema. Compare against the current store schema upfront and abort with a clear error; versionless legacy dumps (Version == 0) are still accepted.
This commit is contained in:
parent
279e908a35
commit
1aecfabe64
1 changed files with 4 additions and 0 deletions
|
|
@ -283,6 +283,10 @@ func (u *Usecase) BackupUser(user *happydns.User) happydns.Backup {
|
|||
}
|
||||
|
||||
func (u *Usecase) Restore(backup *happydns.Backup) error {
|
||||
if current := u.store.SchemaVersion(); backup.Version != 0 && backup.Version != current {
|
||||
return fmt.Errorf("backup schema version %d does not match current database schema version %d", backup.Version, current)
|
||||
}
|
||||
|
||||
var errs error
|
||||
|
||||
// UserAuth
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue