Migrating databases using phpMyAdmin's tracking mechanism

后端 未结 5 1412
悲&欢浪女
悲&欢浪女 2020-12-28 12:05

In a development database, I have phpMyAdmin Tracking enabled on all tables. It logs all the changes I make to the tables\' structures (in this case I\'m not interested in d

5条回答
  •  悲哀的现实
    2020-12-28 12:23

    I've had some success with MySQL Workbench:

    Import (reverse engineer) your dev database into workbench. You can do this by either exporting your schema to an SQL file and loading it into workbench, or workbench will get the schema directly from the server.

    Next, generate your diff file with the "Synchronise model" option. You select the production database, then which tables to sync, and workbench generates an SQL file you can run to sync both models.

    A word of caution: the first time, there will likely be quite a few apparently uneeded changes while the DB is updated to workbench "style". For subsequent updates, the tool is rather reliable, though I would never let an automated tool have free range over my production DB ;-)

    Always check the SQL file for errors, in some cases, dropping a column then adding another of the same name but different type will generate an alter column which will fail.

提交回复
热议问题