How Do I Resolve a Failed SQL Run in Magento 2
Fix SQL errors in Magento 2 installations for successful ShipperHQ setup
Table of Contents
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.
Resolving the Issue
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