Use of MySQL migration tool in production environment

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.