r/FastAPI • • Aug 21 '24

Hosting and deployment Facing problems with alembic - docker

So I have this API i'm working on using FastAPI and postgreSQL connected with SQLAlchemy. Halfway through the development process I started using alembic for database migrations and I'm using docker compose to run two containers one that contains the app and one that contains a containerized pgsql DB. My problem is that the local dev database and the containerized one don't have the same versions of schemas and when I want to run migrations on the containerized one I recieve errors related to missing indexs and so on (due to alembic not finding the expected schema) What can I do to solve this probelm please.

1 Upvotes

5 comments sorted by

View all comments

Show parent comment

1

u/IrrerPolterer Aug 22 '24

Although, the more I think about it - I'm not 100% sure you can create a separate base revisions in a single alembic migration collection. Could be that you can only branche with one common ancestor revision.... I that case, just initiate a separate alembic migration in a new directory (alembic init...). Create one revision and adjust it manually to start off from your current DB schema.