From 2228dfb8ddd24ebc18e891f1b7fbcb11909b6705 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 12 Sep 2025 13:18:40 -0700 Subject: [PATCH] Update utils.py --- src/documents/tests/utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/documents/tests/utils.py b/src/documents/tests/utils.py index 8abbac391..88dddc557 100644 --- a/src/documents/tests/utils.py +++ b/src/documents/tests/utils.py @@ -327,6 +327,19 @@ class TestMigrations(TransactionTestCase): def setUpBeforeMigration(self, apps): pass + def tearDown(self): + """ + Ensure the database schema is restored to the latest migration after + each migration test, so subsequent tests run against HEAD. + """ + try: + executor = MigrationExecutor(connection) + executor.loader.build_graph() + targets = executor.loader.graph.leaf_nodes() + executor.migrate(targets) + finally: + super().tearDown() + class SampleDirMixin: SAMPLE_DIR = Path(__file__).parent / "samples"