开发者

Put MySQL database under version control?

I'm currently using SVN for my PHP projects. I was thinking I should get my database under version control too, but what's the best way to do that? Do I just make a db-folder in my project in S开发者_高级运维VN, paste SQL changes into a file called from_1.0_to_2.0.sql and commit?


Note that in December 2012, you had another option: DBV (DataBase Version)

It is based on this Github project (stalled in 2018), and is a database version control web application featuring schema management, revision scripts, and more.

Put MySQL database under version control?

It has been discontinued since early 2021.


Whenever you make changes to your database, you should save those changes in a migration, that you can then later on run on other servers at the same time you update your code. But you basically got the right idea. You can write some tools to make it more automated; for example version each file, and then create a table like migration_version in your database, which will contain the current version of the database. You can then create a migrate script that will run all the migrations required to get the database up-to-date.

Note that if you want bi-directional db versioning (so that you can revert back to previous db version too), you need to write the required queries for that too for each version.

There are also some tools that can aid you in writing the migrations, such as MySQLdiff


Check out

Liquibase

http://www.liquibase.org/quickstart

The idea is this:

All database changes are stored in a human readable yet trackable form and checked into source control. - Liquibase.org front page

This is a fantastic piece of software that allows you to version your database, in roughly the same process as the top rated answer, except this wheel has already been written and is ready to roll. I use it at work, it's a fantastic solution. Implement it yourself if you want to learn how it works, but Liquibase works great if you want a tool to get things done.


You can use the MySQL Workbench tool.

The file generated with the modeling tool could esaly be saved under SVN. The tool allows you to synchronise your database with the model in bidirectionnal way.


kdbv may its helpful its upgrade your mysql database to current latest version from older without tracking change in mysql tables


Migrations in Laravel - PHP framework seems really useful but there is one big BUT. There is only online tool for designing schema in Laravel ORM language called "Eloquent" (here). So it is still unusable if you need to design and maintain database of some serious project.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜