Altering an FK to a non-FK works (#23244)
(self)
| 5542 | ) |
| 5543 | |
| 5544 | def test_alter_fk_non_fk(self): |
| 5545 | """ |
| 5546 | Altering an FK to a non-FK works (#23244) |
| 5547 | """ |
| 5548 | # Test the state alteration |
| 5549 | operation = migrations.AlterField( |
| 5550 | model_name="Rider", |
| 5551 | name="pony", |
| 5552 | field=models.FloatField(), |
| 5553 | ) |
| 5554 | project_state, new_state = self.make_test_state( |
| 5555 | "test_afknfk", operation, related_model=True |
| 5556 | ) |
| 5557 | # Test the database alteration |
| 5558 | self.assertColumnExists("test_afknfk_rider", "pony_id") |
| 5559 | self.assertColumnNotExists("test_afknfk_rider", "pony") |
| 5560 | with connection.schema_editor() as editor: |
| 5561 | operation.database_forwards("test_afknfk", editor, project_state, new_state) |
| 5562 | self.assertColumnExists("test_afknfk_rider", "pony") |
| 5563 | self.assertColumnNotExists("test_afknfk_rider", "pony_id") |
| 5564 | # And test reversal |
| 5565 | with connection.schema_editor() as editor: |
| 5566 | operation.database_backwards( |
| 5567 | "test_afknfk", editor, new_state, project_state |
| 5568 | ) |
| 5569 | self.assertColumnExists("test_afknfk_rider", "pony_id") |
| 5570 | self.assertColumnNotExists("test_afknfk_rider", "pony") |
| 5571 | |
| 5572 | def test_run_sql(self): |
| 5573 | """ |
nothing calls this directly
no test coverage detected