From 84a2b2e7a7d8ac0dd210bcfa299fab8c4f240aae Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Fri, 4 Nov 2022 09:30:23 +0100 Subject: [4.1.x] Fixed #34138 -- Avoided table rebuild when adding inline m2m fields on SQLite. Regression in 2f73e5406d54cb8945e187eff302a3a3373350be. Thanks David Wobrock for the report. Backport of 7b0e9ea53ca99de2f485ec582f3a79be34b531d4 from main --- django/db/backends/sqlite3/schema.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'django/db/backends/sqlite3/schema.py') diff --git a/django/db/backends/sqlite3/schema.py b/django/db/backends/sqlite3/schema.py index 6c106ae868..88fa466f79 100644 --- a/django/db/backends/sqlite3/schema.py +++ b/django/db/backends/sqlite3/schema.py @@ -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 -- cgit v1.3