Forums / Upgrading to 1.5.x / Database problems after move and upgrade

Database problems after move and upgrade

Started by tkpope on 11 Mar 2015, 4:46 AM · Views: 1,948

Results 1 to 14 of 14
11 Mar 2015, 4:46 AM
#1
tkpope avatar

tkpope

New Zenner

Join Date:
Jul 2009
Posts:
37
Plugin Contributions:
0

Database problems after move and upgrade

I did exactly what ZenCart warned me not to do here:
http://www.zen-cart.com/content.php?142-i-want-to-move-my-zen-cart-installation-to-another-host-or-a-different-server

The previous database (1.3.9) contained over 10,000 orders. The current database (moved from the old host, upgraded to 1.5.4) is not properly recording new orders. I get the following error in the logs:
PHP Fatal error: 1062:Duplicate entry '0' for key 'PRIMARY' :: INSERT INTO zen_orders

It appears that a new entry into orders_id is not being generated. The first order after the move was assigned orders_id 0 (zero) for the following tables (but not orders_id):
orders
orders_products
orders_products_attributes
orders_status_history
orders_total

I doubt there is a simple fix to this problem. That being said, might I want to start the order history over (dropping table info)? Or would that just make matters worse.

I'm willing to take any advice to fix (and scolding for doing what should not have been done).

Thanks in advance,

Sean
+<|:-)

11 Mar 2015, 5:39 AM
#2
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,887
Plugin Contributions:
20

Re: Database problems after move and upgrade

There's just a LOT more we need to know in order to help. It's like you've told us you have a car and it won't run.
The posting tips are there to let you know that everything you can tell us about the situation (even if you think it doesn't apply) might just get a quick, spot on response.

A WAG would be that you did not properly import the old database. Please resist any drastic changes until you give us more information. If you still have backups from the old server, the fix might be quite simple. Hopefully, step six of the link you posted will help BUT, let's wait till we know more.

A properly upgraded site would not have these problems.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

11 Mar 2015, 4:50 PM
#3
tkpope avatar

tkpope

New Zenner

Join Date:
Jul 2009
Posts:
37
Plugin Contributions:
0

Re: Database problems after move and upgrade

What version of Zen Cart are you using? 1.5.4
Has your site been upgraded? When? From what version(s)? Just upgraded from 1.3.9
If you've upgraded, HOW did you upgrade? (official upgrade procedure or an automated script from your hosting company?) Tried to follow the upgrade procedure. Looks like I might have had problems importing the old database.
What plugins/addons have you installed? When? If your problems are payment-related, what payment module(s) are you using? If it's shipping-related, which shipping module(s) are you using? I have installed the following plugins:
CEON URI Mapping
FedEx Express/Ground (not activated)
Referral (How did you find us)
If your problems are language-pack related (non-English), have you checked that all the language files are loaded and correct? The problem is both in English and Spanish
HOW did you install Zen Cart? (upload via FTP and run zc_install, or a one-click install from your hosting company? (one-click installs might mean you don't have enough information about your site/server to make customizations easily)) I uploaded via FTP. Exported/Imported database using phpMyAdmin. The database was too large to import normally, so I used MySQL Workbench
What version of PHP and MySQL is your server using? (See Admin->Tools->Server Info) PHP is 5.4.37 MySQL is 5.5.41-cll-lve
WHEN did the problem "start"? How does that compare with other events of your hosting company, changes you've made to your site files/addons, or your admin settings, etc? Problem occurred on first order and evey order since then
Please post the contents of related "debug logs" generated by Zen Cart (wrap the content in ```
and

PHP Fatal error:  1062:Duplicate entry '0' for key 'PRIMARY' :: INSERT INTO zen_orders
==> (as called by) /home/urbanherbguy583/public_html/store/includes/functions/functions_general.php on line 965 <== in /home/urbanherbguy583/public_html/store/includes/classes/db/mysql/query_factory.php on line 155

If this is your first store, have you tested all aspects of transactions before going live?  Moved the store, not my first store.  
In what ways is your site customized or different from a brand new uncustomized install?  Customized Template files, though these seem to be working fine.
Please post your site URL* so we can take a look at it. This is especially important if you're encountering display/layout problems, so the problem can be seen directly.
<https://herbsofmexico.com/store/>
If you're encountering problems that could be related to your server or hosting company, include the name of your hosting company (not their URL). GoDaddy (moved from HostGator)
HAVE YOU LOOKED IN THE FAQ AREA for answers to your question? (ie: a search for your error message or what you want to edit/change, etc)  Answer is not in the FAQ
Have you searched the FORUM for your error message or for answers to the question you're asking?
Answer is not in the forum (as far as I could find).
11 Mar 2015, 5:21 PM
#4
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,887
Plugin Contributions:
20

Re: Database problems after move and upgrade

The mistake may have been changing the order ID to 0 and leaving in the old orders. Can you check the database and change the order ID to the next hundred from the largest currently. i.e., If it is 962, change the new id to 1000. Let's see if that helps.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

11 Mar 2015, 6:47 PM
#5
tkpope avatar

tkpope

New Zenner

Join Date:
Jul 2009
Posts:
37
Plugin Contributions:
0

Re: Database problems after move and upgrade

I never changed the ID to 0. In fact, once I saw there was a problem with the ID, I went into Admin and changed the order number to 20,000 (we had 10,000 orders previously). That didn't fix the problem either. Now there are orders with orders_id 0, but no new orders are coming in at 20,000+.

11 Mar 2015, 9:29 PM
#6
tkpope avatar

tkpope

New Zenner

Join Date:
Jul 2009
Posts:
37
Plugin Contributions:
0

Re: Database problems after move and upgrade

We are willing to spend money to fix this problem. Please contact me if you think you can help.

12 Mar 2015, 4:41 AM
#7
tkpope avatar

tkpope

New Zenner

Join Date:
Jul 2009
Posts:
37
Plugin Contributions:
0

Re: Database problems after move and upgrade

Don't know what I should do.

12 Mar 2015, 4:22 PM
#8
tkpope avatar

tkpope

New Zenner

Join Date:
Jul 2009
Posts:
37
Plugin Contributions:
0

Re: Database problems after move and upgrade

If I drop all of the records from the orders table, what other tables will be affected?

12 Mar 2015, 5:12 PM
#9
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Database problems after move and upgrade

TKPope:

If I drop all of the records from the orders table, what other tables will be affected?

That's a dangerous thing to do unless you really know what you are doing and know how to recover if/when things go (even more) belly up than they already are.

To answer the question though.

This may not be a complete list. I obtained it from
http://www.zen-cart.com/wiki/index.php/Developers_-_Database_Schema and have no idea how often or when this was last updated.

Order History

files_uploadedorders orders_products orders_products_attributes orders_products_download orders_status_historyorders_total and
paypal
paypal_payment_status_history **paypal_session

Cheers
RodG
**

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

12 Mar 2015, 5:21 PM
#10
tkpope avatar

tkpope

New Zenner

Join Date:
Jul 2009
Posts:
37
Plugin Contributions:
0

Re: Database problems after move and upgrade

Rod - I appreciate the response. It may be dangerous, but I currently have a site that's not working. I don't know what to do, and I don't know if that will fix the problem. All of the data (good and bad) is backed up, so it's at least something that might be worth trying to see if that works.

12 Mar 2015, 5:27 PM
#11
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Database problems after move and upgrade

TKPope:

Rod - I appreciate the response. It may be dangerous, but I currently have a site that's not working. I don't know what to do, and I don't know if that will fix the problem. All of the data (good and bad) is backed up, so it's at least something that might be worth trying to see if that works.

The safe thing to do would be to drop the entire database and replace it with the most current backup of the original site.

Yes, I realise that it is from a different version of ZenCart, but all being well the new zencart version will detect that it's an old version DB and give you the option to update it.

This would certainly be the approach I'd be taking rather than run the risk of getting a mish mash of table data.

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

13 Mar 2015, 4:02 AM
#12
tkpope avatar

tkpope

New Zenner

Join Date:
Jul 2009
Posts:
37
Plugin Contributions:
0

Re: Database problems after move and upgrade

I emptied all of the orders tables and imported good data for those tables. When I tried placing an order, the following debug file was created:

[13-Mar-2015 03:48:15 UTC] PHP Fatal error: 2013:Lost connection to MySQL server during query :: select p.products_id, p.products_image
from zen_orders_products opa, zen_orders_products opb, zen_orders o, zen_products p
where opa.products_id = '2133'
and opa.orders_id = opb.orders_id
and opb.products_id != '2133'
and opb.products_id = p.products_id
and opb.orders_id = o.orders_id
and p.products_status = 1
group by p.products_id
order by o.date_purchased desc
limit 6 ==> (as called by) /store/includes/modules/also_purchased_products.php on line 16 <== in /store/includes/classes/db/mysql/query_factory.php on line 155

Still having the same problem with incrementing the orders_id. Even though I asked for the next number to be 12000, it still came in as 0 (zero). I have a feeling this is due to some other coding issue and not a database problem after all. I just don't know where to look and fix.

13 Mar 2015, 4:50 AM
#13
tkpope avatar

tkpope

New Zenner

Join Date:
Jul 2009
Posts:
37
Plugin Contributions:
0

Re: Database problems after move and upgrade

In fact, orders_id has no record of this order at all. It is not recorded in the database. So, whatever is going on, orders_id is not being incremented nor is it being recorded.

14 Mar 2015, 9:50 AM
#14
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Database problems after move and upgrade

TKPope:

Still having the same problem with incrementing the orders_id. Even though I asked for the next number to be 12000, it still came in as 0 (zero). I have a feeling this is due to some other coding issue and not a database problem after all. I just don't know where to look and fix.

I really wish I could help more, but since you choose to try to keep doing it your way rather than the way I suggested (and would do if I were in your position) there really isn't much more than I can say, other than you probably missed one of the needed tables.

Cheers
RodG

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.