From 7e60a117d854bd569a7aafbd09dff4bf4e425115 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 24 Sep 2022 15:09:58 +0200 Subject: fix downgrade not picking the right revisions If we apply a migration that takes us from "v1" to "v2", then a downgrade needs to apply the reverse of this migration - not the one that goes from "v1" to "v0", and not "no migration". The previous code managed to not do this, as it would see "v1-v2" as applied and therefore skip it. --- fietsboek/updater/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fietsboek/updater/__init__.py b/fietsboek/updater/__init__.py index 6c154e7..8ca4991 100644 --- a/fietsboek/updater/__init__.py +++ b/fietsboek/updater/__init__.py @@ -124,7 +124,7 @@ class Updater: def _reverse_versions(self): all_versions = set(script.id for script in self.scripts.values()) - return (all_versions - self._transitive_versions()) | set(self.current_versions()) + return (all_versions - self._transitive_versions()) def stamp(self, versions): """Stampts the given version into the version file. @@ -201,6 +201,7 @@ class Updater: # dependencies instead. applied_versions = self._reverse_versions() to_apply = self._pick_updates(target, applied_versions, self.backward_dependencies) + to_apply -= {target} application_queue = self._make_schedule(to_apply, self.backward_dependencies) LOGGER.debug("Planned downgrade: %s", application_queue) for downgrade in application_queue: -- cgit v1.2.3