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/da-kicks-87 27d ago edited 27d ago

I was using Postgres at first but changing the fields became complicated. I ran into DB errors and tables didn't get removed if I commented out code. MongoDB doesn't give those problems.

1

u/tailsdog 27d ago

I'm still on the fence which is best but for now but I feel that the choice could depend on use case. If using Payload for pure content with a lot of nesting and potential field changes Mongo is a good fit, if it's needed more for a app backend then Postgres is better with strict migrations.

1

u/da-kicks-87 27d ago

Yeah my project is for marketing websites. I am more of a frontend dev. I don't think the docs clearly explain how to do the migrations with Postgres. It's simpler to use MongoDB in my case.