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:
nemunaire 2026-06-04 15:09:39 +09:00
commit 1aecfabe64

View file

@ -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