In the company project, I am fortunate to be responsible for the production of "Upgrade scripts." Upgrade script, no doubt two steps, first structure comparison, and then the initial data alignment.
First, the structure comparison
The structure is relatively simple, using the navicat for MySQL tool, "tools"-"Structure Synchronization", select the "source", "target", "Alignment Options", click "Alignment." (If you need to upgrade the database V4 to V5)
Copy the SQL statement that synchronizes the structure, as shown in the following figure
Second, data synchronization
Right-click "Select All", "Run Query", achieve structure synchronization, then need data alignment.
In the project, as the development progresses, the initial data may change, such as the refactoring of the permission module and the addition of new features.
Navicat for MySQL has "data synchronization", but cannot display "data alignment" to produce SQL statements.
2.1 Manual Comparison
Very helpless, using the project SVN submitted SQL version number comparison, right click "Compare Revisions"
Perhaps because I have a large SQL script file, the following unexpected situation occurs:
On the Internet to check some information, found that there is a "beyond compare" text compared to the tool, feel the same as SVN's comparison. Download Address: http://www.scootersoftware.com/download.php
2.2 Auto Comparison
After the bitter-forced comparison, complete the task. I try to find this kind of software again. Found a red Gate company MySQL compare (including MySQL data Compare) software to meet my basic requirements, unfortunately, there are garbled, for example, in my SQL script, Chinese compared to the "???." The latest version of the software is 2012 and no one is maintaining upgrades. Foreigners also have such confusion, give up.
Download Address: http://www.red-gate.com/products/mysql/mysql-compare/
The surprise is, finally found a satisfactory software tool---dbforge Compare Bundle for MySQL, download address: http://www.devart.com/downloads.html
This software is very similar to the MySQL compare, for often with Navicat for MySQL friend is very simple, compare, click Sync.
Create a script file and open it using the built-in editor
The refreshing SQL script comes out and is simply manually modified to suit the needs of the project.
Finally, combining transactions, write stored procedures.