MySQL Schema Diff Generator

Blog

At work, I occasionally need to move database changes from the development server to the live server.  We have about a hundred tables, which makes it difficult to review by hand.  So there is a comparison script that basically runs a `mysqladmin` schema dump on both databases and then diffs the two files.  The result is a little difficult to decipher at times and still requires manual scripting to make the final ALTER commands.

What if I could run a PHP script that would compare any two schemas and generate proper ALTER commands to correct the two of them.  I would probably use some combination of these SQL commands:

  • SHOW TABLES
  • SHOW CREATE TABLE ‘tablename’
  • SHOW COLUMNS FROM ‘tablename’

I’m going to have to think about this tonight.  Maybe punch out a test script tomorrow.

No Comments

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



  • Donate

    If my work has helped you and you want to return the favor, you could purchase something for me from my Amazon Wish List or send me a donation via PayPal.

  • License

    Unless otherwise noted, all source code and compiled files published on this website are released under the terms of the GNU Lesser General Public License.