|
|
|
Ask HN: How do you version control a Database?
|
|
8 points
by 719Ben
3983 days ago
|
|
Hello All, I am working on a project with 2 others and we have a PostgreSQL database that links to our project. We are trying to figure out the best way to share the layout of the database as it is edited.
Currently we email each other when we change the table layout but this takes a lot of time and feels very backwards from regular Git commits.
Does anyone have any advice to version controlling a database layout? We could care less about the actual data at this point because we are still developing the system. |
|
* Put your schema/data migrations into .sql files as raw SQL
* Number the files from 0001 on
* Write a script to apply each migration file to the DB in order, recording the file name to a log table after successful application. Only apply migrations not found in the log table.
* Commit your .sql migration files along with the code it is tied to.