Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do database version control without migration of specific framework? [closed]

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.

like image 881
cytsunny Avatar asked Aug 19 '15 11:08

cytsunny


1 Answers

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.

like image 79
HPierce Avatar answered Nov 15 '22 16:11

HPierce