mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #34027 -- Fixed migrations crash when altering type of char/text fields referenced by foreign key on PostgreSQL.
This commit is contained in:
committed by
Mariusz Felisiak
parent
50096a3a7a
commit
9f8c994851
@@ -2436,6 +2436,45 @@ class OperationTests(OperationTestBase):
|
||||
],
|
||||
)
|
||||
|
||||
def test_alter_field_pk_fk_char_to_int(self):
|
||||
app_label = "alter_field_pk_fk_char_to_int"
|
||||
project_state = self.apply_operations(
|
||||
app_label,
|
||||
ProjectState(),
|
||||
operations=[
|
||||
migrations.CreateModel(
|
||||
name="Parent",
|
||||
fields=[
|
||||
("id", models.CharField(max_length=255, primary_key=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Child",
|
||||
fields=[
|
||||
("id", models.BigAutoField(primary_key=True)),
|
||||
(
|
||||
"parent",
|
||||
models.ForeignKey(
|
||||
f"{app_label}.Parent",
|
||||
on_delete=models.CASCADE,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
self.apply_operations(
|
||||
app_label,
|
||||
project_state,
|
||||
operations=[
|
||||
migrations.AlterField(
|
||||
model_name="parent",
|
||||
name="id",
|
||||
field=models.BigIntegerField(primary_key=True),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
def test_rename_field_reloads_state_on_fk_target_changes(self):
|
||||
"""
|
||||
If RenameField doesn't reload state appropriately, the AlterField
|
||||
|
||||
Reference in New Issue
Block a user