aerich
aerich copied to clipboard
Guide: Integrate to zalando postgres operator and FastAPI in Kubernetes cluster
I have a zalando postgres-operator based database cluster on my k8 cluster. I have a separate FastAPI + tortoise ORM app. Tortoise uses the postgres db generated by the operator.
How do I integrate aerich
to this workflow?
I was thinking of just having a startup script that runs and applies migrations at the during pod/container startup:
aerich init -t <some path>
aerich init-db
aerich migrate
aerich upgrade
<run WSGI or ASGI server command>
Any improvements or better ideas alltogether?
What about this https://github.com/tortoise/aerich#use-aerich-in-application?
What about this https://github.com/tortoise/aerich#use-aerich-in-application?
Should I keep this as test
? Or just blank -> update
?
await command.migrate("test")
What about this https://github.com/tortoise/aerich#use-aerich-in-application?
Should I keep this as
test
? Or just blank ->update
?await command.migrate("test")
@caniko
Migrate.migrate
just reads models to generate a new migration file.
You could use await command.upgrade()
instead, in order to apply existing migrations. This way your database will be in the expected state after a new migration is submitted.
Can you guys activate discussions? This issue should probably become a thread. Closing it makes no sense.
You can migrate use aerich migrate
command local, and use Command
to do auto upgrade when application startup, just call the init
and upgrade
method