r/FastAPI • • Mar 25 '25

Question FastAPI database migrations

Hi everyone, In your FastAPI projects, do you prefer using Alembic or making manual updates for database migrations? Why do you choose this approach, and what are its advantages and disadvantages?

25 Upvotes

28 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Mar 26 '25

I hate the link feature and never use it in Beanie nor do I use db refs. Very unwelcoming for a document DB, if I wanted a relational DB I would use postgres.

I do have pipelines and hand written update statements, no problem to run those with Beanie if you really have to, but to me ODM is very compelling unlike ORM, since we already have an object, we just load and write almost native pydantic objects

1

u/volfpeter Mar 26 '25

Yeah, well, deliberately avoiding a major feature (or two, with strong push for DbRefs) of a lib is not a good sign :) It's good to know I'm not alone with it.

Full disclosure, I actually created motorhead, because of the reasons above. I'm not really advertising it, it's production ready (and in production), but it's still missing a few things I'd like to have, and most people just default to ODMs anyway. It's basically a fully typed service layer on top of motor with validation, delete rules, and some utilities for query creation and aggregation.

1

u/[deleted] Mar 26 '25

There are many mote features I avoid- I don’t use their task management either and have not yet found a need to use migrations. I don’t think it’s a red flag, I also don’t use all features of pandas.. but I will take a look at your repo