1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #23273 -- Avoided creation of django_migrations table when there are no migrations to apply.

This commit is contained in:
Jacob Walls
2021-12-28 10:46:42 -05:00
committed by Mariusz Felisiak
parent 361bb8f786
commit 92412aa94c
3 changed files with 46 additions and 5 deletions

View File

@@ -759,6 +759,17 @@ class ExecutorTests(MigrationTestBase):
False,
)
@mock.patch.object(MigrationRecorder, 'has_table', return_value=False)
def test_migrate_skips_schema_creation(self, mocked_has_table):
"""
The django_migrations table is not created if there are no migrations
to record.
"""
executor = MigrationExecutor(connection)
# 0 queries, since the query for has_table is being mocked.
with self.assertNumQueries(0):
executor.migrate([], plan=[])
class FakeLoader:
def __init__(self, graph, applied):