HACKER Q&A
📣 rafaelquicdb

How do you manage dev/PR/staging databases?


Do you use e.g. pg_dump/restore? What's your DB size & team size? Is it working fine? Any pain points?


  👤 benoau Accepted Answer ✓
There's version control for databases that expresses your database schema as code, and changes as code that is applied incrementally, such as Liquibase or Sequelize Migrations. When you create a new DB you are just running a command to build it from that code to the exact same state as your application needs. I'm partial to just bundling this within the backend project so it's available for CI, tests and local development too.

https://www.liquibase.com/

https://sequelize.org/docs/v6/other-topics/migrations/

Basically, you have a starting state where you create a users table and sessions table, and then you have a change file whenever you added some column or made some modification or added another table. Sequelize also manages populating data which they call seeding it so if you had like a geoip dataset you would have a file that inserts it.