summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2020-08-24 00:45:48 -0400
committerGitHub <noreply@github.com>2020-08-24 06:45:48 +0200
commit7ca42974ee087a82b6f7f6874ca2b25e42a9a584 (patch)
tree868fae41207cabbfeb3f627420e15d2294e34750
parent3e753d3de33469493b1f0947a2e0152c4000ed40 (diff)
Added assertions for the results of migrating an integer pk to AutoField.
-rw-r--r--tests/schema/tests.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index d31a12e504..e516b17b59 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -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):
"""