Is it appropriate to use some code like this to, programatically run migrations #1304
-
|
This is slightly related to #1248 (but that's about the CLI check command to return some information). In my case, I'm trying to do the same, using the So I've ended with something like this in my app startup: # Let's check if there are pending migrations.
if pending := await CheckMigrationManager(app_name="all").havent_ran_count(): # Because `check()` does not return anything.
logger.warning(f"DB migrations to run: {pending}")
await forwards.forwards(app_name="all")
else:
logger.info("DB is up to date. No migrations to run.")(note that I've been also playing with the So, the question is, basically, if to use those (check, forwards, ...) managers is considered ok or I can face problems in the future. Ciao :-) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Using And yeah, using |
Beta Was this translation helpful? Give feedback.
Using
await CheckMigrationManager(app_name="all").havent_ran_count()is the right solution for finding it any migrations haven't run.And yeah, using
run_forwardsorforwardsis absolutely fine 👍