1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #34138 -- Avoided table rebuild when adding inline m2m fields on SQLite.

Regression in 2f73e5406d.

Thanks David Wobrock for the report.
This commit is contained in:
Mariusz Felisiak
2022-11-04 09:30:23 +01:00
committed by GitHub
parent 0f4964535c
commit 7b0e9ea53c
3 changed files with 24 additions and 3 deletions

View File

@@ -379,7 +379,10 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
def add_field(self, model, field):
"""Create a field on a model."""
if (
# Special-case implicit M2M tables.
if field.many_to_many and field.remote_field.through._meta.auto_created:
self.create_model(field.remote_field.through)
elif (
# Primary keys and unique fields are not supported in ALTER TABLE
# ADD COLUMN.
field.primary_key