Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2011
    Location
    Adelaide, Australia
    Posts
    1,670
    Plugin Contributions
    1

    Default DataBase query after upgrade

    v1.5.7b

    I've just upgraded from 1.55f to 1.5.7b and all went very well with the exception of 1 issue with the database. It is more my lack of understanding of MySQL rather than an issue.

    Between staring to build the upgraded site and making it live there were some orders received on the live 1.5.5f site. I did an export from the live site database of the tables I required, i.e. orders, order status etc - customers, address book , customer info etc. So I did a custom export ticking the tables I wanted I then imported those tables into the new database but that created a problem, parts of admin went blank and an error warning showed up.

    I then reinstalled the saved copy of the new database and all was fine - but orders and customers are not up to date. I then just exported the lines within the orders table only and imported them, again an sql error showed in phpMyAdmin (see below) - didn't affect my admin but still the orders are not updated.

    So what is the correct way to obtain the data I want from the old database and then put it into the new database?

    I'd really appreciate some assistance.

    cheers, Mike

    Code:
    Error
    
    SQL query:
    
    --
    -- Database: `dazzler3_155fjuly2020`
    --
    
    -- --------------------------------------------------------
    
    --
    -- Table structure for table `orders`
    --
    
    CREATE TABLE `orders` (
      `orders_id` int(11) NOT NULL,
      `customers_id` int(11) NOT NULL DEFAULT 0,
      `customers_name` varchar(64) NOT NULL DEFAULT '',
      `customers_company` varchar(64) DEFAULT NULL,
      `customers_street_address` varchar(64) NOT NULL DEFAULT '',
      `customers_suburb` varchar(32) DEFAULT NULL,
      `customers_city` varchar(32) NOT NULL DEFAULT '',
      `customers_postcode` varchar(10) NOT NULL DEFAULT '',
      `customers_state` varchar(32) DEFAULT NULL,
      `customers_country` varchar(32) NOT NULL DEFAULT '',
      `customers_telephone` varchar(32) NOT NULL DEFAULT '',
      `customers_email_address` varchar(96) NOT NULL DEFAULT '',
      `customers_address_format_id` int(5) NOT NULL DEFAULT 0,
      `delivery_name` varchar(64) NOT NULL DEFAULT '',
      `delivery_company` varchar(64) DEFAULT NULL,
      `delivery_street_address` varchar(64) NOT NULL DEFAULT[...]
    
    MySQL said: Documentation
    #1050 - Table 'orders' already exists

  2. #2
    Join Date
    Apr 2013
    Location
    eglisau switzerland
    Posts
    567
    Plugin Contributions
    0

    Default Re: DataBase query after upgrade

    I am by no means an SQL expert but I believe you should somehow use the INSERT command not CREATE, maybe read up on it?

  3. #3
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: DataBase query after upgrade

    The live database should continue to operate and process orders until the new store is being put into place and operational.... What that means is while you are testing your rebuild/upgrade the database that you are accessing should be independent of your live site and *WILL* become out-of-date... Once the upgrade looks like it is good *AND* you have tested doing the upgrade of the database (import of copy of live store to this rebuild area and database upgrade), *THEN* it is time to temporarily place the live site in maintenance mode, either move the files or redirect visitors to your new location so that access to your normal site location is to the new fileset. Before again taking the site out of maintenance mode, update the database, verify that store is operational and then take it out of maintenance mode.

    The time during which the site is in maintenance mode based on the above could be as short as a few minutes but plan for about an hour just to be sure that all is working as it should...

    As far as the issue about doing this potentially dangerous database data move, which even now your new site is going to have out-of-date information, the table should only be created if it is missing or doesn't exist:

    Code:
    CREATE TABLE IF NOT EXISTS `orders`(
    This should be a selection option when exporting the existing table from phpMyAdmin, though there still is the concern about other records that *should* be moved, but have not been selected.

    Please re-review the guidance on updating: [FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]https://docs.zen-cart.com/user/upgrading/detailed_upgrading/[/FONT]
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Jan 2011
    Location
    Adelaide, Australia
    Posts
    1,670
    Plugin Contributions
    1

    Default Re: DataBase query after upgrade

    Quote Originally Posted by mc12345678 View Post
    The live database should continue to operate and process orders until the new store is being put into place and operational.... What that means is while you are testing your rebuild/upgrade the database that you are accessing should be independent of your live site and *WILL* become out-of-date... Once the upgrade looks like it is good *AND* you have tested doing the upgrade of the database (import of copy of live store to this rebuild area and database upgrade), *THEN* it is time to temporarily place the live site in maintenance mode, either move the files or redirect visitors to your new location so that access to your normal site location is to the new fileset. Before again taking the site out of maintenance mode, update the database, verify that store is operational and then take it out of maintenance mode.

    The time during which the site is in maintenance mode based on the above could be as short as a few minutes but plan for about an hour just to be sure that all is working as it should...

    As far as the issue about doing this potentially dangerous database data move, which even now your new site is going to have out-of-date information, the table should only be created if it is missing or doesn't exist:

    Code:
    CREATE TABLE IF NOT EXISTS `orders`(
    This should be a selection option when exporting the existing table from phpMyAdmin, though there still is the concern about other records that *should* be moved, but have not been selected.

    Please re-review the guidance on updating: [FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]https://docs.zen-cart.com/user/upgrading/detailed_upgrading/[/FONT]
    Thanks MC,

    I thought I'd followed the upgrade correctly in respect to the database, but obviously not. I built the site in a folder in the root using the rebuild process, not a normal upgrade - after installing the new version I copied the existing database from the live site to the new rebuild and did the update.

    Seems I should have copied across the existing database into the new rebuild after testing it and just before going live?

    So to try to recover the DB situation I could delete the tables in the new 1.5.7b site, then import the tables from the 1.5.5f DB which is more current - obviously it would need to be done one after the other in quick time with site in maintenance mode - as long as I have full backup copies of both databases I at least will have a fall back position.

    I think now that I have made a right royal mess of the upgrade - may need to restore the old site and start again.
    Last edited by shags38; 19 Jan 2021 at 01:40 PM.

  5. #5
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: DataBase query after upgrade

    Seems like when you created the database backup/export you didn't include the "Drop Tables" option which deletes any pre-existing table when importing.
    That option is often "unchecked" by default so that people don't accidentally wipe out production databases by importing to the wrong destination, and implies that the person using the exported data to import into another database will first make sure those tables don't already exist (eg: delete/drop them manually, or use a new clean database) in the database they're restoring into.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Jan 2011
    Location
    Adelaide, Australia
    Posts
    1,670
    Plugin Contributions
    1

    Default Re: DataBase query after upgrade

    Quote Originally Posted by DrByte View Post
    Seems like when you created the database backup/export you didn't include the "Drop Tables" option which deletes any pre-existing table when importing.
    That option is often "unchecked" by default so that people don't accidentally wipe out production databases by importing to the wrong destination, and implies that the person using the exported data to import into another database will first make sure those tables don't already exist (eg: delete/drop them manually, or use a new clean database) in the database they're restoring into.
    Thanks DrByte - that is what I've done - I normally religiously check the add drop tables when exporting, someone told me that many moons ago - at about 1:00am or so this morning, tired and frustrated, and only exporting a couple of tables I ommited to check that box - my fault. So from what you are saying, if I repeat the process making sure I check the add drop tables in the export then the import process will drop the existing tables and import those in the exported sql ... have I got that right?

    again many thanks,
    cheers
    Mike

  7. #7
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: DataBase query after upgrade

    Quote Originally Posted by shags38 View Post
    if I repeat the process making sure I check the add drop tables in the export then the import process will drop the existing tables and import those in the exported sql ... have I got that right?
    Yes, when you tick the drop-tables checkbox and select some tables to export, importing that exported file will first drop each table before recreating and loading that table with whatever is in the export file, table by table.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Jan 2011
    Location
    Adelaide, Australia
    Posts
    1,670
    Plugin Contributions
    1

    Default Re: DataBase query after upgrade

    Quote Originally Posted by DrByte View Post
    Yes, when you tick the drop-tables checkbox and select some tables to export, importing that exported file will first drop each table before recreating and loading that table with whatever is in the export file, table by table.
    Thanks for the reply DrByte - so I followed that process and it went OK at phpMyAdmin, no errors, no warnings and I could see the tables had been adjusted .... however in ZC admin half the home page was blank, the RH side section that shows customers, orders, stats etc, as was admin/customers and admin/orders ... so I reinstalled my saved master copy of the database and everything was reinstated, minus the extra data I was trying to retrieve.

    I can live without that data being added but just wondered if you had thoughts as to why this would occur?

    cheers,
    Mike

  9. #9
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: DataBase query after upgrade

    Quote Originally Posted by shags38 View Post
    Thanks for the reply DrByte - so I followed that process and it went OK at phpMyAdmin, no errors, no warnings and I could see the tables had been adjusted .... however in ZC admin half the home page was blank, the RH side section that shows customers, orders, stats etc, as was admin/customers and admin/orders ... so I reinstalled my saved master copy of the database and everything was reinstated, minus the extra data I was trying to retrieve.

    I can live without that data being added but just wondered if you had thoughts as to why this would occur?

    cheers,
    Mike
    If the data pulled was not of the current ZC version, then it would need to be updated through the zc_install process... This can be done through jumping through other hoops, but ultimately the data needs to only be the most up-to-date when it is time to make the data part of the new live site under the new software... That is why there is the process described previously (though I didn't provide the link to the "simple" upgrade by rebuild process which I expect to be linked from what I previously provided... FYI, I'm still working on my level of familiarity with the new instruction considering I have limited ways by which to access and search it because of my own issues.)

    As for the issues that occurred and has been suggested time and again, check your logs folder... When something stops being presented it is because of an error of some sort. More than likely the cause will be logged in one way or another... Obviously it is possible that there is incorrect logic that will give "unexpected" results though the results that were programmed.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v151 Smaller database after upgrade.
    By MoonCow in forum Upgrading to 1.5.x
    Replies: 2
    Last Post: 2 Apr 2013, 03:22 PM
  2. Replies: 5
    Last Post: 6 Oct 2012, 08:53 PM
  3. Re-install to upgrade to 1.3.8 database query
    By rubear in forum Upgrading from 1.3.x to 1.3.9
    Replies: 12
    Last Post: 18 Mar 2008, 05:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR