diff options
| author | Simon Charette <charette.s@gmail.com> | 2018-12-06 11:37:43 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-12-07 14:22:27 -0500 |
| commit | fc8c2284e9f9e8d5d17ef35f282917a6833fafed (patch) | |
| tree | 95d599385f1c121516b301d2c40ec1196545e04a /django/db/backends/sqlite3/schema.py | |
| parent | 4c506730b5a8dae2ab9a16712db2f39c21d4385a (diff) | |
[2.1.x] Fixed #29182 -- Fixed schema table alteration on SQLite 3.26+.
SQLite 3.26 repoints foreign key constraints on table renames even when
foreign_keys pragma is off which breaks every operation that requires
a table rebuild to simulate unsupported ALTER TABLE statements.
The newly introduced legacy_alter_table pragma disables this behavior
and restores the previous schema editor assumptions.
Thanks Florian Apolloner, Christoph Trassl, Chris Lamb for the report and
troubleshooting assistance.
Backport of c8ffdbe514b55ff5c9a2b8cb8bbdf2d3978c188f from master.
Diffstat (limited to 'django/db/backends/sqlite3/schema.py')
| -rw-r--r-- | django/db/backends/sqlite3/schema.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/django/db/backends/sqlite3/schema.py b/django/db/backends/sqlite3/schema.py index b27d39d732..e0d8135cbd 100644 --- a/django/db/backends/sqlite3/schema.py +++ b/django/db/backends/sqlite3/schema.py @@ -21,10 +21,12 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): # Some SQLite schema alterations need foreign key constraints to be # disabled. Enforce it here for the duration of the transaction. self.connection.disable_constraint_checking() + self.connection.cursor().execute('PRAGMA legacy_alter_table = ON') return super().__enter__() def __exit__(self, exc_type, exc_value, traceback): super().__exit__(exc_type, exc_value, traceback) + self.connection.cursor().execute('PRAGMA legacy_alter_table = OFF') self.connection.enable_constraint_checking() def quote_value(self, value): |
