diff --git a/tests/schema/models.py b/tests/schema/models.py
index 4512d8bc01..f6bdbd8815 100644
a
|
b
|
class Author(models.Model):
|
12 | 12 | name = models.CharField(max_length=255) |
13 | 13 | height = models.PositiveIntegerField(null=True, blank=True) |
14 | 14 | weight = models.IntegerField(null=True, blank=True) |
| 15 | uuid = models.UUIDField(null=True) |
15 | 16 | |
16 | 17 | class Meta: |
17 | 18 | apps = new_apps |
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index e1bf438ca3..32e4a28e10 100644
a
|
b
|
from django.db.models.deletion import CASCADE, PROTECT
|
12 | 12 | from django.db.models.fields import ( |
13 | 13 | AutoField, BigAutoField, BigIntegerField, BinaryField, BooleanField, |
14 | 14 | CharField, DateField, DateTimeField, IntegerField, PositiveIntegerField, |
15 | | SlugField, TextField, TimeField, |
| 15 | SlugField, TextField, TimeField, UUIDField, |
16 | 16 | ) |
17 | 17 | from django.db.models.fields.related import ( |
18 | 18 | ForeignKey, ForeignObject, ManyToManyField, OneToOneField, |
… |
… |
class SchemaTests(TransactionTestCase):
|
603 | 603 | with connection.schema_editor() as editor: |
604 | 604 | editor.alter_field(Author, old_field, new_field, strict=True) |
605 | 605 | |
| 606 | def test_alter_nullable_uuid_to_primary_key(self): |
| 607 | # Create the table |
| 608 | with connection.schema_editor() as editor: |
| 609 | editor.create_model(Author) |
| 610 | # Change UUIDField to PrimaryKey |
| 611 | old_field = Author._meta.get_field('uuid') |
| 612 | new_field = UUIDField(primary_key=True) |
| 613 | new_field.set_attributes_from_name('uuid') |
| 614 | new_field.model = Author |
| 615 | with connection.schema_editor() as editor: |
| 616 | editor.remove_field(Author, Author._meta.get_field('id')) |
| 617 | editor.alter_field(Author, old_field, new_field, strict=True) |
| 618 | |
606 | 619 | def test_alter_text_field(self): |
607 | 620 | # Regression for "BLOB/TEXT column 'info' can't have a default value") |
608 | 621 | # on MySQL. |