Django migration revert: will the operations be reverted in reverse order?

Viewed 171

I have three operations in my migration file. The first operation needs to happen first for the other 2 operations to run without issues. My understanding is that the operations will happen in order, but what if I wanna revert the migrations? Are the 3 operations reverted in reverse order, i.e., the RunPython will be reverted last?

operations = [
    migrations.RunPython(migrate_forward, reverse_code=migrate_backward),
    migrations.AlterField(...),
    migrations.AddField(...),
]
1 Answers

I tested in my dev env and found that the operations ARE INDEED reverted in the reverse order.

Related