From d6068f6297ee1cc218df06435cbb4ace7eb49415 Mon Sep 17 00:00:00 2001 From: Georgiy Tarasov Date: Mon, 16 Dec 2024 12:39:39 +0100 Subject: [PATCH 1/3] fix: restore the latest migration after migration tests --- posthog/test/base.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/posthog/test/base.py b/posthog/test/base.py index 707b445f0840c..e277642dec294 100644 --- a/posthog/test/base.py +++ b/posthog/test/base.py @@ -792,6 +792,13 @@ def _execute_migration_with_snapshots(self, executor): def setUpBeforeMigration(self, apps): pass + def tearDown(self): + super().tearDown() + 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): """ From 1f993e8f193627be925508702c578136c5097e4a Mon Sep 17 00:00:00 2001 From: Georgiy Tarasov Date: Mon, 16 Dec 2024 13:08:53 +0100 Subject: [PATCH 2/3] fix: test --- posthog/test/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posthog/test/base.py b/posthog/test/base.py index e277642dec294..934a4eb99b48a 100644 --- a/posthog/test/base.py +++ b/posthog/test/base.py @@ -793,7 +793,7 @@ def setUpBeforeMigration(self, apps): pass def tearDown(self): - super().tearDown() + super().tearDown() # type: ignore executor = MigrationExecutor(connection) # Reset Django's migration state targets = executor.loader.graph.leaf_nodes() executor.migrate(targets) # Migrate to the latest migration From 448daa37b9cb260d56237d6c37d412b1aecdfa21 Mon Sep 17 00:00:00 2001 From: Georgiy Tarasov Date: Mon, 16 Dec 2024 14:43:07 +0100 Subject: [PATCH 3/3] fix: use tearDownClass --- posthog/test/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/posthog/test/base.py b/posthog/test/base.py index 934a4eb99b48a..a8a06dcf3e480 100644 --- a/posthog/test/base.py +++ b/posthog/test/base.py @@ -792,8 +792,9 @@ def _execute_migration_with_snapshots(self, executor): def setUpBeforeMigration(self, apps): pass - def tearDown(self): - super().tearDown() # type: ignore + @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