How Do I Resolve a Failed SQL Run in Magento
Fix SQL errors in Magento installations for successful ShipperHQ setup
- Overview
- Magento 1
- Manually rewind core_resource
- Script delete/rewind coreresource (Recommended)
- Delete coreresource
- Rewind Resource
- Magento 2
- Further Help 😊
Overview
When you install the ShipperHQ extension, it usually runs SQL as part of the installation. If you see an error report on the frontend afterward, it might be due to the SQL not running successfully or a mistake in file copying. Common reasons for SQL errors include:
- Unique Index Too Long
- The SQL has already run on this server, causing a conflict by attempting to run twice (rare and happens if the database was manually modified)
- The frontend was updated during installation, attempting to run SQL install or upgrade before files were present
You may encounter errors like SQLSTATE[42S02]: Base Table Or View Not Found. Before proceeding, ensure:
- All files are installed correctly (including Common/Logger)
- Check the report in
var/reportfor clues about the issue
If attributes are missing or tables not found, it's likely issue 3 above. You can resolve this by rewinding the core_resource.
Magento 1
Manually rewind core_resource
Follow these steps to resolve the issue. It's recommended to be familiar with phpMyAdmin; otherwise, consult a developer:
- Take a full database backup
- Locate the 'core_resource' table
- Browse the table for the entry causing the issue (e.g.,
shipperhq_shipper_setup) - Remove that entry alone
- Ensure cache is switched off
- Refresh the frontend
- Check that the install script has now run and created the missing tables and attributes
Script delete/rewind core_resource (Recommended)
We offer a script to delete/rewind the core_resource entry. Ensure you have the latest WSA Common installed to run the script successfully.
Delete core_resource
Use this script only if it's the first installation of this extension. ⚠️ Disclaimer - Do not use this script unless confident. WebShopApps/ShipperHQ cannot be held responsible for the outcome.
- Take a full database backup
- Add the script file (setResource.php) to the base of your Magento install
- Navigate to your base Magento URL followed by '/setResource.php' (e.g.,
www.magento.com/setResource.php) - Select the extension from the dropdown, which may require running in multiple parts. If you can't see your extension, add the
core_resourcecode manually (e.g.,shipperhq_shipper_setup) - Click
Show Current Resource Versionto continue - Click
deleteto remove thecore_resourcerow corresponding to your extension - Refresh the frontend
- Verify the script has run correctly, creating the attributes
- If there's an error related to another table, revisit
setResource.phpand select the next module - Remove the script file after use
Rewind Resource
This same script includes a rewind option that rolls back to an earlier version, prompting Magento to run the upgrade script for the SQL. Use only if confident, as WebShopApps/ShipperHQ is not responsible for outcomes.
- Take a full database backup
- Add the script file (setResource.php) to the base of your Magento install
- Navigate to your base Magento URL followed by '/setResource.php'
- Select the extension from the dropdown. If not visible, add the
core_resourcecode manually by referencingapp/code/community/shipperhq/module name/etc/config.xml - Click
Show Current Resource Versionto continue - Note and roll-back the module version if needed (e.g., from 1.0.6 to 1.0.5)
- Click rewind
- Refresh the frontend
- Verify the script has run correctly, creating the attributes
- Remove the script file after use
Magento 2
To resolve the issue:
- Take a full database backup
- Locate the 'setup_module' table
- Browse the table for the entry causing the issue (e.g.,
shipperhq_shipper) - Remove that entry alone
- Run
php bin/magento setup:upgradefrom the command line - Refresh indexes, compiler (if enabled), and cache (if enabled)
- Refresh the frontend
- Verify that the install script has run and created the missing tables and attributes
Further Help 😊
If problems persist:
- Identify the actual error. If only a report number is given, locate the report in the
var/reportsdirectory - Disable the extension for further inspection
- Contact ShipperHQ Support with your order details, error report, and description of the issue for diagnosis