From 790d108c97f0cf9caa02c72791f2bf158d308fcd Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Fri, 21 Dec 2018 19:47:47 -0500 Subject: [PATCH] Refs #30033 -- Checked constraints before committing SQLite schema changes. This order of operations is more in line with SQLite's documented table rebuild procedure and ensures that changes aren't committed if foreign key integrity is broken. --- django/db/backends/sqlite3/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django/db/backends/sqlite3/schema.py b/django/db/backends/sqlite3/schema.py index edc128fca2..1a4b94fa82 100644 --- a/django/db/backends/sqlite3/schema.py +++ b/django/db/backends/sqlite3/schema.py @@ -30,8 +30,8 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): return super().__enter__() def __exit__(self, exc_type, exc_value, traceback): - super().__exit__(exc_type, exc_value, traceback) self.connection.check_constraints() + super().__exit__(exc_type, exc_value, traceback) self.connection.enable_constraint_checking() def quote_value(self, value):