|
29 | 29 | from django.core.cache import cache |
30 | 30 | from django.db import connection, connections |
31 | 31 | from django.db.migrations.executor import MigrationExecutor |
32 | | -from django.db.migrations.state import ProjectState |
33 | 32 | from django.http import HttpRequest |
34 | 33 | from django.test import RequestFactory |
35 | 34 | from django.test import TestCase as DjangoTestCase |
@@ -2673,20 +2672,6 @@ def create_user_member_role(self): |
2673 | 2672 | self.login_as(self.user) |
2674 | 2673 |
|
2675 | 2674 |
|
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 | | - |
2690 | 2675 | @pytest.mark.migrations |
2691 | 2676 | class TestMigrations(TransactionTestCase): |
2692 | 2677 | """ |
@@ -2727,22 +2712,22 @@ def setUp(self): |
2727 | 2712 | old_apps = executor.loader.project_state(migrate_from).apps |
2728 | 2713 |
|
2729 | 2714 | # Reverse to the original migration |
2730 | | - executor.migrate(migrate_from, state=get_project_state(self.connection)) |
| 2715 | + executor.migrate(migrate_from) |
2731 | 2716 |
|
2732 | 2717 | self.setup_before_migration(old_apps) |
2733 | 2718 |
|
2734 | 2719 | # Run the migration to test |
2735 | 2720 | executor = MigrationExecutor(connection) |
2736 | 2721 | executor.loader.build_graph() # reload. |
2737 | | - executor.migrate(migrate_to, state=get_project_state(self.connection)) |
| 2722 | + executor.migrate(migrate_to) |
2738 | 2723 |
|
2739 | 2724 | self.apps = executor.loader.project_state(migrate_to).apps |
2740 | 2725 |
|
2741 | 2726 | def tearDown(self): |
2742 | 2727 | super().tearDown() |
2743 | 2728 | executor = MigrationExecutor(connection) |
2744 | 2729 | executor.loader.build_graph() # reload. |
2745 | | - executor.migrate(self.current_migration, state=get_project_state(self.connection)) |
| 2730 | + executor.migrate(self.current_migration) |
2746 | 2731 |
|
2747 | 2732 | def setup_initial_state(self): |
2748 | 2733 | # Add code here that will run before we roll back the database to the `migrate_from` |
|
0 commit comments