I've adjusted the migrations file manually to avoid dropping/re-creating
columns. The migration looks like this now:
{{{
operations = [
migrations.AlterField(
model_name='suggestion',
name='source_id',
field=models.ForeignKey(db_column=b'source_id',
to_field=b'source_id', to='mps_v2.CommitteeResolution'),
preserve_default=False,
),
migrations.RenameField(
model_name='suggestion',
old_name='source_id',
new_name='source_resolution',
),
migrations.AlterUniqueTogether(
name='suggestion',
unique_together=set([('source_resolution', 'source_index')]),
),
]
}}}
The forward migration is exactly as I expect it to be:
{{{
$ django-admin sqlmigrate mps_v2 0029
BEGIN;
ALTER TABLE `mps_v2_suggestion` ADD CONSTRAINT
`D58bb2cf0b1407c8c24fa06b0cc34f38` FOREIGN KEY (`source_id`) REFERENCES
`mps_v2_committeeresolution` (`source_id`);
COMMIT;
}}}
I expect the reverse migration to drop the constraint.
It doesn't:
{{{
$ django-admin sqlmigrate mps_v2 0029 --backwards
}}}
(there's no output).
--
Ticket URL: <https://code.djangoproject.com/ticket/25621>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
What database are you using? Could you provide a complete minimal project
that reproduces it?
--
Ticket URL: <https://code.djangoproject.com/ticket/25621#comment:1>
Comment (by mgedmin):
MySQL (unfortunately).
The actual project where I stumbled upon this is open source:
https://github.com/ManoSeimas/manoseimas.lt/blob/master/manoseimas/mps_v2/migrations/0029_link_suggestion_to_committeeresolution.py
I'll try to provide a minimal example.
--
Ticket URL: <https://code.djangoproject.com/ticket/25621#comment:2>
* status: new => closed
* resolution: => needsinfo
--
Ticket URL: <https://code.djangoproject.com/ticket/25621#comment:3>