2

Just had a client enter a large amount of content (400+ articles) onto our development built by accident, trying to work out a cunning way of merging the live database with the development database without losing any information. Is there any easy ways to do this?

A different editor has also been adding content into the live site so i'm guessing it could get pretty complicated?

3

Well, that all depends on what kind of data was entered. Every fieldtype adds complexity - relationships, Playa, Matrix, Assets, Tag, categories - these all add new rows to additional database tables after the standard channel_titles and channel_data.

The main thing to worry about is duplicate entry_ids. My tactic here is to go through each relevant entry and add a sufficiently-large number to the entry_id in every applicable table. So, say your production site has less than 100 new entries since the development database was last synced:

UPDATE exp_channel_titles SET entry_id = entry_id + 100 WHERE entry_id IN(<!-- comma-delimited list of the new entry_ids you need to migrate -->)
UPDATE exp_channel_data SET entry_id = entry_id + 100 WHERE entry_id IN(<!-- same list of entry_ids -->)

If you have relationships, other complex fieldtypes which use their own table that references the entry_id of the entry their data is associated with, you'll need to do work on those as well.

After you've sufficiently incremented all these values, you can merge the DBs.

| improve this answer | |
  • Cheers Derek, this looks great, will give it a go! – Nick Mar 6 '13 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.