If this is your first visit, check our documentation. To post, register or login.
Forums / Configuring the Zen Cart Admin / Managing Customers and Orders / Best way to merge two databases to preserve customers and orders

Best way to merge two databases to preserve customers and orders

Started by roodney on 8 Apr 2019, 3:02 PM · Views: 8,827

Results 1 to 4 of 4
8 Apr 2019, 3:02 PM
#1
roodney avatar

roodney

New Zenner

Join Date:
Jul 2011
Posts:
27
Plugin Contributions:
0

Best way to merge two databases to preserve customers and orders

Using v 1.5.5
My host did a restoration of our website from two weeks ago due to a file being overwritten that we couldn't track down which caused the checkout process to loop (for new customers) and now checkout is working again. The problem is I was planning on restoring the database from the most recent version since orders have come in but we had new orders overnight that are now in the current db which I would prefer to preserve, but they have order numbers/etc that are duplicates now.
So what is the best way to include the new orders into a restored version of yesterdays database files (with the newest orders)? Is it possible just to manually add the new entries in the orders and customers table using phpmyadmin or are there other tables of concern?

8 Apr 2019, 5:58 PM
#2
roodney avatar

roodney

New Zenner

Join Date:
Jul 2011
Posts:
27
Plugin Contributions:
0

Re: Best way to merge two databases to preserve customers and orders

I think I figured it out. For reference (my own included since I like to repeat mistakes).
After making a backup of the current db I replaced the store database with the older one, thus replacing the new orders (there were only a couple so this seemed like the easier option) with the ones that were lost in the first backup restore. Then I just manually entered the missing order info into the various tables; in this case I believe they were orders, orders_products, orders_status_history, orders_total and paypal. There might be other db's affected, I used notepad ++ to find all occurrences of the order_id that I was inserting and then when putting together the sql insert command I updated the order id/order_products_id/order_status_history_id/etc with the current numbers (since the id numbers all had to be adjusted to account for the existing orders).
Basically the older db was restored bringing back all orders from the last two weeks, then the individual db entries were added in phpmyadmin to the end of their respective tables so everything is almost fine I think.

8 Apr 2019, 7:43 PM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Best way to merge two databases to preserve customers and orders

Thing about this is that:

  1. the email sent to the affected customer(s) indicates a different order number than currently assigned.
  2. there's no history in the admin history nor order history showing the change.

There may be some other things to address that I've missed.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

8 Apr 2019, 8:51 PM
#4
roodney avatar

roodney

New Zenner

Join Date:
Jul 2011
Posts:
27
Plugin Contributions:
0

Re: Best way to merge two databases to preserve customers and orders

mc12345678:

Thing about this is that:

  1. the email sent to the affected customer(s) indicates a different order number than currently assigned.
  2. there's no history in the admin history nor order history showing the change.

There may be some other things to address that I've missed.

That's true, you could always add an entry to the admin_history table to remedy that and yes the order number is different, that's the only noticeable and unavoidable byproduct of trying to fix it this way. In my case I printed out invoices for affected orders before the order number changed so they would only recognize the differences by logging into their accounts and comparing invoice numbers. I was unsure of another way to handle the situation, for me the small amount of affected customers (only orders placed overnight yesterday) was acceptable and I couldn't come up with a better solution in a short time frame.