How can I put a database under git (version control)?
Use something like LiquiBase this lets you keep revision control of your Liquibase files. you can tag changes for production only, and have lb keep your DB up to date for either production or development, (or whatever scheme you want).
I'm starting to think of a really simple solution, don't know why I didn't think of it before!!
- Duplicate the database, (both the schema and the data).
- In the branch for the new-major-changes, simply change the project configuration to use the new duplicate database.
This way I can switch branches without worrying about database schema changes.
EDIT:
By duplicate, I mean create another database with a different name (like my_db_2
); not doing a dump or anything like that.
Take a database dump, and version control that instead. This way it is a flat text file.
Personally I suggest that you keep both a data dump, and a schema dump. This way using diff it becomes fairly easy to see what changed in the schema from revision to revision.
If you are making big changes, you should have a secondary database that you make the new schema changes to and not touch the old one since as you said you are making a branch.
- Irmin (branching + time travel)
- Flur.ee (immutable + time travel + graph query)
- XTDB (formerly called 'CruxDB') (time travel + query)
- TerminusDB (immutable + branching + time travel + Graph Query!)
- DoltDB (branching + time-travel + SQL query)
- Quadrable (branching + remote state verification)
- EdgeDB (no real time travel, but migrations derived by the compiler after schema changes)
- Migra (diffing for Postgres schemas/data. Auto-generate migration scripts, auto-sync db state)
- ImmuDB (immutable + time-travel)