1👍
✅
The RunSQL
migration [Django-doc] takes a second optional parameter where you can specify the reverse migration, so:
class Migration(migrations.Migration):
dependencies = [('polls', '0001_initial')]
operations = [
migrations.RunSQL(
'ALTER TABLE comments RENAME COLUMN contents TO text;',
'ALTER TABLE comments RENAME COLUMN text TO contents;',
),
]
If you then migrate to:
manage.py migrate polls 0001
it will look if all migrations have a reverse operation, and take that query.
Source:stackexchange.com