From 16730d38f5139f58c8de3b1e04b23269c9e6dafe Mon Sep 17 00:00:00 2001 From: Georgiy Tarasov Date: Tue, 17 Dec 2024 00:32:28 +0100 Subject: [PATCH] fix(tests): restore the latest migration after migration tests (#26928) --- posthog/test/base.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/posthog/test/base.py b/posthog/test/base.py index 707b445f0840c..a8a06dcf3e480 100644 --- a/posthog/test/base.py +++ b/posthog/test/base.py @@ -792,6 +792,14 @@ def _execute_migration_with_snapshots(self, executor): def setUpBeforeMigration(self, apps): pass + @classmethod + def tearDownClass(cls): + super().tearDownClass() # type: ignore + executor = MigrationExecutor(connection) # Reset Django's migration state + targets = executor.loader.graph.leaf_nodes() + executor.migrate(targets) # Migrate to the latest migration + executor.loader.build_graph() # Reload. + class TestMigrations(BaseTestMigrations, BaseTest): """