I know migration is one way to do version control on database schema. However, as I have a database that is shared by multiple project and every project may change the schema a bit. So, I would need something like branch and merge function like git for codes, where migration cannot give such function. So, is there a version control tools specifically for database?
We are using php with laravel and mysql for database, and we are willing to switch to postgresql if needed.
You can set up all of your setup .sql
files within the git repository for the project. Because you mentioned many projects use this database, it might be wise to use a single repository exclusively for the database:
Consider that the following directory is managed by git:
setup.php
setup/
----- Create_database.sql
----- Create_users_table.sql
----- Create_posts_table.sql
----- Create_some_view.sql
setup.php
can now be used to execute all of the .sql
files within the setup directory to make the database easier to deploy/clone. When you need to make a change to your database, simply use the features already built into git to branch and merge changes into this repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With