In the process of product iterative development and release, due to the increase in business requirements, the database will inevitably have structure adjustment and other operations. How to control the server end of each version during the release process
In the process of product iterative development and release, due to the increase in business requirements, the database will inevitably have structure adjustment and other operations. How to control the server end of each version during the release process
In the process of product iterative development and release, due to the increase in business requirements, the database will inevitably have structure adjustment and other operations.
During the release of each version, how does one control the consistency between the server program and the database version, as well as Database Upgrade and rollback operations.
This blog post will recommend a mysql database migration tool, mysql-php-migrations.
Because of the different requirements, the house bird made some modifications to mysql-php-migrations based on the situation of its own company to fill the application!
The mysql migration program after the house bird program is modified has the following directory:
Config configuration file
Dbscript SQL Script directory
Lib migration program class library
Migrate. php migration Command Execution Portal
Execute php migrate. php
The following result is displayed:
We can see that migrate. php has many commands.
Php migrate. php add test
Result:
________
| \/| (_/\ | _ |__) |__ | |__) _ | \/|. _ | _.___
| \/_) \ _ \/|__ | (_) | )_)
/_/
**************************************** * *************************** V2.0.1 ***
New migration created: file
/Var/www/mysqlMigrations/dbscript/2013_12_18_14_50_45_test.php
**************************************** ***************************************
Cd dbscript
Total 16
-Rw-r -- 1 www-data 4837 Sep 29 2013_06_18_17_14_16_v1.php
-Rw-r -- 1 www-data 802 Sep 29 2013_09_29_12_00_12_v1.php
-Rw-r -- 1 root www-data 240 Dec 18 :50 2013_12_18_14_50_45_test.php
At this time, a new 2013_12_18_14_50_45_test.php file has been added to the dbscript directory. The file format is as follows:
Class Migration_2013_12_18_14_50_45 extends MpmMysqliMigration
{
Public function up (ExceptionalMysqli & $ mysqli)
{
$ Mysqli-> exec ("DO 0 ");
}
Public function down (ExceptionalMysqli & $ mysqli)
{
$ Mysqli-> exec ("DO 0 ");
}
}
?>
Write the database script to be modified in the up function:
Unmount the rollback operation corresponding to the modification in the down function.
Note: In the production environment, we recommend that you only change the database upwards without going down to avoid the loss of useful data.