Upgrade matomo to 4.x: incorrect SQL statement errors out

I’m trying to upgrade matomo from 3.x to 4.x, and I’m getting the following errors:

Error trying to execute the migration 'ALTER TABLE `log_visit` MODIFY COLUMN `visitor_count_visits` INT(11) UNSIGNED NOT NULL DEFAULT 0, MODIFY COLUMN `visit_total_interactions` MEDIUMINT UNSIGNED DEFAULT 0, MODIFY COLUMN `referer_name` VARCHAR(255) NULL, MODIFY COLUMN `referer_url` VARCHAR(1500) NULL, MODIFY COLUMN `config_browser_name` VARCHAR(40) NULL, MODIFY COLUMN `config_client_type` TINYINT( 1 ) NULL DEFAULT NULL, MODIFY COLUMN `location_region` char(3) DEFAULT NULL, MODIFY COLUMN `location_region` char(3) DEFAULT NULL;'.                                   
The error was: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'location_region' in 'log_visit'

Note that the error isn’t about location_region column itself, but that MODIFY COLUMN `location_region` appears twice. Does anyone know how I can skip this sql statement?

OK, I resolved this by downgrading and reupgrading. Still, I have no idea why this erroneous sql statement occurred before. Perhaps because my installation has experienced 5-year span and perhaps a lot of old files existed in the previous version that weren’t properly cleaned.

1 Like