Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guide: Integrate to zalando postgres operator and FastAPI in Kubernetes cluster #254

Open
caniko opened this issue Aug 10, 2022 · 5 comments

Comments

@caniko
Copy link

caniko commented Aug 10, 2022

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?

@long2ice
Copy link
Member

What about this https://github.com/tortoise/aerich#use-aerich-in-application?

@caniko
Copy link
Author

caniko commented Aug 10, 2022

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")

@isaquealves
Copy link
Contributor

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.

@caniko
Copy link
Author

caniko commented Aug 10, 2022

Can you guys activate discussions? This issue should probably become a thread. Closing it makes no sense.

@long2ice
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants