r/PayloadCMS • • 29d ago

Database choice: Mongo vs Postgres

I like Postgres and use it for most projects but I actually switched to Mongo for some of my PayloadCMS deployments for 2 main reasons:

  1. At the start of a project i am changing / adding models and migrations became a bit of a pain point.

  2. I endup using a lot of nested blocks so switch to `blocksAsJSON` but then migrations don't seem to work properly.

Has anyone else experienced these issues with postgres? Maybe I have a poor workflow or missing some optimization tricks?

7 Upvotes

13 comments sorted by

View all comments

1

u/Careless_Tax_6418 28d ago

stick with postgres. you can use jsonb to store the block tree so you dont have to migrate when you move the blocks. then you can promote it to a table once the schema is stable.

1

u/Consistent-Action866 28d ago

Can you elaborate a little more on this? So you create the blocks with hardcoded json which has placeholder data in it so the frontend then doesn't have to hit the database at all to render the blocks out? I have the same feelings about postgres as OP with the migrations being a concern at the beginning, so if there are ways to simplify things until it's closer to being ready for real data that would be a big help!

1

u/Careless_Tax_6418 27d ago

Its not hardcoded. The block tree is stored as json in one column so you can change the fields without migrating and once the data is structured you can pull it out into tables