| 1461 | @skipUnlessDBFeature('supports_foreign_keys') |
| 1462 | def test_alter_field_reloads_state_on_fk_with_to_field_target_type_change(self): |
| 1463 | app_label = 'alter_alter_field_reloads_state_on_fk_with_to_field_target_type_change' |
| 1464 | project_state = self.apply_operations(app_label, ProjectState(), operations=[ |
| 1465 | migrations.CreateModel('Rider', fields=[ |
| 1466 | ('id', models.AutoField(primary_key=True)), |
| 1467 | ('code', models.PositiveIntegerField(unique=True)), |
| 1468 | ]), |
| 1469 | migrations.CreateModel('Pony', fields=[ |
| 1470 | ('id', models.AutoField(primary_key=True)), |
| 1471 | ('rider', models.ForeignKey('%s.Rider' % app_label, models.CASCADE, to_field='code')), |
| 1472 | ]), |
| 1473 | ]) |
| 1474 | project_state = self.apply_operations(app_label, project_state, operations=[ |
| 1475 | migrations.AlterField('Rider', 'code', models.CharField(max_length=100, unique=True)), |
| 1476 | ]) |
| 1477 | |
| 1478 | @skipUnlessDBFeature('supports_foreign_keys') |
| 1479 | def test_alter_field_reloads_state_on_fk_with_to_field_related_name_target_type_change(self): |
| 1480 | app_label = 'alter_alter_field_reloads_state_on_fk_with_to_field_related_name_target_type_change' |
| 1481 | project_state = self.apply_operations(app_label, ProjectState(), operations=[ |
| 1482 | migrations.CreateModel('Rider', fields=[ |
| 1483 | ('id', models.AutoField(primary_key=True)), |
| 1484 | ('code', models.PositiveIntegerField(unique=True)), |
| 1485 | ]), |
| 1486 | migrations.CreateModel('Pony', fields=[ |
| 1487 | ('id', models.AutoField(primary_key=True)), |
| 1488 | ('rider', models.ForeignKey('%s.Rider' % app_label, models.CASCADE, to_field='code', related_name='+')), |
| 1489 | ]), |
| 1490 | ]) |
| 1491 | project_state = self.apply_operations(app_label, project_state, operations=[ |
| 1492 | migrations.AlterField('Rider', 'code', models.CharField(max_length=100, unique=True)), |
| 1493 | ]) |
| 1494 | |