summaryrefslogtreecommitdiff
path: root/django/db/backends/oracle/schema.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/backends/oracle/schema.py')
-rw-r--r--django/db/backends/oracle/schema.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/django/db/backends/oracle/schema.py b/django/db/backends/oracle/schema.py
index d6585a80ca..002cb9e48b 100644
--- a/django/db/backends/oracle/schema.py
+++ b/django/db/backends/oracle/schema.py
@@ -122,6 +122,17 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
# Rename and possibly make the new field NOT NULL
super().alter_field(model, new_temp_field, new_field)
+ def _alter_column_type_sql(self, model, old_field, new_field, new_type):
+ auto_field_types = {'AutoField', 'BigAutoField', 'SmallAutoField'}
+ # Drop the identity if migrating away from AutoField.
+ if (
+ old_field.get_internal_type() in auto_field_types and
+ new_field.get_internal_type() not in auto_field_types and
+ self._is_identity_column(model._meta.db_table, new_field.column)
+ ):
+ self._drop_identity(model._meta.db_table, new_field.column)
+ return super()._alter_column_type_sql(model, old_field, new_field, new_type)
+
def normalize_name(self, name):
"""
Get the properly shortened and uppercased identifier as returned by