mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Refs #30664 -- Fixed migrations crash when altering AutoField/BigAutoField with quoted db_column on PostgreSQL.
This commit is contained in:
@@ -636,6 +636,26 @@ class SchemaTests(TransactionTestCase):
|
||||
with connection.schema_editor() as editor:
|
||||
editor.alter_field(Author, old_field, new_field, strict=True)
|
||||
|
||||
@isolate_apps('schema')
|
||||
def test_alter_auto_field_quoted_db_column(self):
|
||||
class Foo(Model):
|
||||
id = AutoField(primary_key=True, db_column='"quoted_id"')
|
||||
|
||||
class Meta:
|
||||
app_label = 'schema'
|
||||
|
||||
with connection.schema_editor() as editor:
|
||||
editor.create_model(Foo)
|
||||
self.isolated_local_models = [Foo]
|
||||
old_field = Foo._meta.get_field('id')
|
||||
new_field = BigAutoField(primary_key=True)
|
||||
new_field.model = Foo
|
||||
new_field.db_column = '"quoted_id"'
|
||||
new_field.set_attributes_from_name('id')
|
||||
with connection.schema_editor() as editor:
|
||||
editor.alter_field(Foo, old_field, new_field, strict=True)
|
||||
Foo.objects.create()
|
||||
|
||||
def test_alter_not_unique_field_to_primary_key(self):
|
||||
# Create the table.
|
||||
with connection.schema_editor() as editor:
|
||||
|
||||
Reference in New Issue
Block a user