Sample Header Ad - 728x90

Replicate data between MySQL servers with a different structure

1 vote
1 answer
743 views
As part of a system upgrade I need to sync a database between 2 different servers (master-master). The catch is that the structure is slightly different between the 2. Most of the differences are:- - Columns that exist in 1 but not the other and need populating based on other fields/tables - Type changes where some integer fields are now enums with text values that will need mapping from a static list - Multiple tables have been merged into 1 So far I've been thinking about setting triggers up which would catch all INSERT/UPDATE/DELETE statements and insert them into a "queue" table. A PHP script would then convert the data and write the changes to the other server. All queries in the system are executed through a central database object so I could potentially add some code to parse each query, create a new query that works with the other server and execute both queries together. There's also the possibility to only use the new database and use query parsing code to re-format the data on each read/write to make it compatible with the old system. Data has to be copied both ways (master-master) and it has to be as close to realtime as possible. Has anyone got any better suggestions or advice on how to do this?
Asked by SPKSmithy (11 rep)
Sep 7, 2017, 11:42 AM
Last activity: Apr 17, 2025, 10:04 AM