summaryrefslogtreecommitdiff
path: root/django/db/backends/oracle/schema.py
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-04-29 21:43:55 +0200
committerGitHub <noreply@github.com>2022-04-29 21:43:55 +0200
commit1b3a949ba26ca8fefde7fa224e11c4aadbbdd724 (patch)
tree04bd3b26c8a0ea04eecd59389dbd39104a96c3ee /django/db/backends/oracle/schema.py
parentf0ba799edf4f9948da28b5df2000a092ad6a150d (diff)
downloaddjango-1b3a949ba26ca8fefde7fa224e11c4aadbbdd724.tar.gz
Refs #33671 -- Fixed migrations crash when adding collation to a primary key on Oracle.
Diffstat (limited to 'django/db/backends/oracle/schema.py')
-rw-r--r--django/db/backends/oracle/schema.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/django/db/backends/oracle/schema.py b/django/db/backends/oracle/schema.py
index d6b04fe9a1..f2a5099110 100644
--- a/django/db/backends/oracle/schema.py
+++ b/django/db/backends/oracle/schema.py
@@ -91,6 +91,14 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
elif "ORA-30673" in description and old_field.primary_key:
self._delete_primary_key(model, strict=True)
self._alter_field_type_workaround(model, old_field, new_field)
+ # If a collation is changing on a primary key, drop the primary key
+ # first.
+ elif "ORA-43923" in description and old_field.primary_key:
+ self._delete_primary_key(model, strict=True)
+ self.alter_field(model, old_field, new_field, strict)
+ # Restore a primary key, if needed.
+ if new_field.primary_key:
+ self.execute(self._create_primary_key_sql(model, new_field))
else:
raise