Added assertions for the results of migrating an integer pk to AutoField.
@@ -1346,6 +1346,20 @@ class SchemaTests(TransactionTestCase):
with connection.schema_editor() as editor:
editor.alter_field(IntegerPK, old_field, new_field, strict=True)
+ # A model representing the updated model.
+ class IntegerPKToAutoField(Model):
+ i = AutoField(primary_key=True)
+ j = IntegerField(unique=True)
+
+ class Meta:
+ app_label = 'schema'
+ apps = new_apps
+ db_table = IntegerPK._meta.db_table
+
+ # An id (i) is generated by the database.
+ obj = IntegerPKToAutoField.objects.create(j=1)
+ self.assertIsNotNone(obj.i)
+
def test_alter_int_pk_to_bigautofield_pk(self):
"""
Should be able to rename an IntegerField(primary_key=True) to
@@ -1362,6 +1376,20 @@ class SchemaTests(TransactionTestCase):
with connection.schema_editor() as editor:
editor.alter_field(IntegerPK, old_field, new_field, strict=True)
+ # A model representing the updated model.
+ class IntegerPKToBigAutoField(Model):
+ i = BigAutoField(primary_key=True)
+ j = IntegerField(unique=True)
+
+ class Meta:
+ app_label = 'schema'
+ apps = new_apps
+ db_table = IntegerPK._meta.db_table
+
+ # An id (i) is generated by the database.
+ obj = IntegerPKToBigAutoField.objects.create(j=1)
+ self.assertIsNotNone(obj.i)
+
@isolate_apps('schema')
def test_alter_smallint_pk_to_smallautofield_pk(self):
"""
