summaryrefslogtreecommitdiff
path: root/django/db/backends/oracle/schema.py
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2020-08-22 14:32:01 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-08-24 14:32:07 +0200
commitea880ec233ecd61c20b74eb7d6d1cf1223897179 (patch)
tree622df7f048970ed97fec1ce67781059039563535 /django/db/backends/oracle/schema.py
parentb3124215117541a86b0740314ef991e1d521da69 (diff)
downloaddjango-ea880ec233ecd61c20b74eb7d6d1cf1223897179.tar.gz
Fixed #24533 -- Dropped PostgreSQL sequence and Oracle identity when migrating away from AutoField.
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