diff --git a/tests/schema/tests.py b/tests/schema/tests.py index 3a2947cf43..33a4bc527b 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -2160,6 +2160,19 @@ class SchemaTests(TransactionTestCase): with connection.schema_editor() as editor: editor.alter_field(SmallIntegerPK, old_field, new_field, strict=True) + # A model representing the updated model. + class IntegerPKToSmallAutoField(Model): + i = SmallAutoField(primary_key=True) + + class Meta: + app_label = "schema" + apps = new_apps + db_table = SmallIntegerPK._meta.db_table + + # An id (i) is generated by the database. + obj = IntegerPKToSmallAutoField.objects.create() + self.assertIsNotNone(obj.i) + @isolate_apps("schema") @unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL specific") def test_alter_serial_auto_field_to_bigautofield(self):