Skip to content

Commit a394f69

Browse files
Revert "perf(migrations): Improve performance of migration tests a little (#86007)"
This reverts commit 1117c03. Co-authored-by: wedamija <[email protected]>
1 parent 1117c03 commit a394f69

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

src/sentry/testutils/cases.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from django.core.cache import cache
3030
from django.db import connection, connections
3131
from django.db.migrations.executor import MigrationExecutor
32-
from django.db.migrations.state import ProjectState
3332
from django.http import HttpRequest
3433
from django.test import RequestFactory
3534
from django.test import TestCase as DjangoTestCase
@@ -2673,20 +2672,6 @@ def create_user_member_role(self):
26732672
self.login_as(self.user)
26742673

26752674

2676-
_project_state_cache: dict[str, ProjectState] = {}
2677-
2678-
2679-
def get_project_state(connection: str) -> ProjectState:
2680-
global _project_state_cache
2681-
2682-
if connection not in _project_state_cache:
2683-
executor = MigrationExecutor(connections[connection])
2684-
_project_state_cache[connection] = executor._create_project_state(
2685-
with_applied_migrations=True
2686-
)
2687-
return _project_state_cache[connection].clone()
2688-
2689-
26902675
@pytest.mark.migrations
26912676
class TestMigrations(TransactionTestCase):
26922677
"""
@@ -2727,22 +2712,22 @@ def setUp(self):
27272712
old_apps = executor.loader.project_state(migrate_from).apps
27282713

27292714
# Reverse to the original migration
2730-
executor.migrate(migrate_from, state=get_project_state(self.connection))
2715+
executor.migrate(migrate_from)
27312716

27322717
self.setup_before_migration(old_apps)
27332718

27342719
# Run the migration to test
27352720
executor = MigrationExecutor(connection)
27362721
executor.loader.build_graph() # reload.
2737-
executor.migrate(migrate_to, state=get_project_state(self.connection))
2722+
executor.migrate(migrate_to)
27382723

27392724
self.apps = executor.loader.project_state(migrate_to).apps
27402725

27412726
def tearDown(self):
27422727
super().tearDown()
27432728
executor = MigrationExecutor(connection)
27442729
executor.loader.build_graph() # reload.
2745-
executor.migrate(self.current_migration, state=get_project_state(self.connection))
2730+
executor.migrate(self.current_migration)
27462731

27472732
def setup_initial_state(self):
27482733
# Add code here that will run before we roll back the database to the `migrate_from`

0 commit comments

Comments
 (0)