I always thought that dependencies made sure that all the migrations that I put there ran before the migraton I was declaring. However, today I found about run_before and Im not sure what are the differences between both. Can someon clarify the difference between run_before
and dependencies
when declaring a Django migration?
class Migration(migrations.Migration):
dependencies = [
('myapp', '0123_the_previous_migration'),
]
run_before = [
('third_party_app', '0001_do_awesome'),
]
run_before
is the exact opposite of dependencies
. You should read it as "this migration must run before these other migrations".
Generally you should be using dependencies
over run_before
. One use-case where you need run_before
is if an external app has a dependency in some way on one of your migrations.
This is also explained in "Controlling the order of migrations".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With