From 6f9c6678bffc4f660382fa6c8836ba2d55dc3c2b Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 30 Aug 2024 20:17:17 -0400 Subject: [PATCH] Added assertion for the results of migrating an integer pk to SmallAutoField. Follow up to 7ca42974ee087a82b6f7f6874ca2b25e42a9a584 which did the same for similar tests. --- tests/schema/tests.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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):