1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #33125 -- Avoided redundant unique constraint when converting a non-unique field to primary key on MySQL and PostgreSQL.

This commit is contained in:
Jordan Bae
2021-09-25 12:59:36 +09:00
committed by Mariusz Felisiak
parent 4ffada3609
commit f5a3243911
3 changed files with 11 additions and 8 deletions

View File

@@ -741,6 +741,13 @@ class SchemaTests(TransactionTestCase):
with connection.schema_editor() as editor:
editor.remove_field(Author, Author._meta.get_field('id'))
editor.alter_field(Author, old_field, new_field, strict=True)
# Redundant unique constraint is not added.
count = self.get_constraints_count(
Author._meta.db_table,
Author._meta.get_field('uuid').column,
None,
)
self.assertLessEqual(count['uniques'], 1)
@isolate_apps('schema')
def test_alter_primary_key_quoted_db_table(self):