diff options
author | David Wobrock <david.wobrock@gmail.com> | 2022-05-02 14:43:35 +0200 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-05-04 12:15:00 +0200 |
commit | 8f04473af1da1ed4e8a07e89205da4e70d69b586 (patch) | |
tree | 2ecc4b39a4725649b2842a69048170bba87e111f /django/db/backends/postgresql/schema.py | |
parent | fde946daffbb007a7d033945677cc8e9e475d516 (diff) | |
download | django-8f04473af1da1ed4e8a07e89205da4e70d69b586.tar.gz |
Fixed #25105 -- Checked deferred constraints before updating rows on PostgreSQL.
Diffstat (limited to 'django/db/backends/postgresql/schema.py')
-rw-r--r-- | django/db/backends/postgresql/schema.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/django/db/backends/postgresql/schema.py b/django/db/backends/postgresql/schema.py index 3053c8d370..a22ae0094f 100644 --- a/django/db/backends/postgresql/schema.py +++ b/django/db/backends/postgresql/schema.py @@ -7,6 +7,13 @@ from django.db.backends.utils import strip_quotes class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): + # Setting all constraints to IMMEDIATE to allow changing data in the same + # transaction. + sql_update_with_default = ( + "UPDATE %(table)s SET %(column)s = %(default)s WHERE %(column)s IS NULL" + "; SET CONSTRAINTS ALL IMMEDIATE" + ) + sql_delete_sequence = "DROP SEQUENCE IF EXISTS %(sequence)s CASCADE" sql_create_index = ( |