Upgrade error - unknown column 'entity_modified_date' in 'civicrm_managed'
Overview
I've come across an issue when upgrading a site from CiviCRM 5.33.5 to CiviCRM 5.45.1.
Looking at the error log, I think the issue is that the upgrade process is trying to set the entity_modified_date
in civicrm_managed
before this field is created.
I think the error occurs when the upgrader is running the upgrade_5_39_alpha1
in /CRM/Upgrade/Incremental/php/FiveThirtyNine.php
. The post hook calls /CRM/Core/BAO/Managed.php
(which was added in CiviCRM 5.45). Line 37 of which executes this SQL:
UPDATE civicrm_managed SET entity_modified_date = CURRENT_TIMESTAMP WHERE entity_type = 'SavedSearch' AND entity_id = 348;
This fails with an error, because entity_modified_date
field isn't added until CiviCRM 5.45. It is added in /CRM/Upgrade/Incremental/php/FiveFortyFive.php
.
Reproduction steps
Update from CiviCRM 5.33.5 to CiviCRM 5.45.1 using cv upgrade:db
.
Presumably the site needs to have some saved searches that are modified in the 5.39 upgrade process.
Current behaviour
Upgrade fails with error:
Dropping SQL triggers...
Preparing upgrade...
Executing upgrade...
...................................................PHP Warning: A non-numeric value encountered in phar:///usr/local/bin/cv/vendor/symfony/console/Output/Output.php on line 145
Warning: A non-numeric value encountered in phar:///usr/local/bin/cv/vendor/symfony/console/Output/Output.php on line 145
PHP Warning: A non-numeric value encountered in phar:///usr/local/bin/cv/vendor/symfony/console/Output/Output.php on line 148
Warning: A non-numeric value encountered in phar:///usr/local/bin/cv/vendor/symfony/console/Output/Output.php on line 148
Error executing task: %s
[CiviCRM_API3_Exception]
DB Error: no such field
Expected behaviour
Upgrade completes successfully.
Environment information
- Browser: N/A
- CiviCRM: 5.33.5 to 5.45.1
- PHP: 7.3
- CMS: WordPress 5.4
- Database: MySQL 5.7.27
- Web Server: Nginx 1.15.0
Comments
Possibly related error reported here: https://civicrm.stackexchange.com/questions/41040/upgrade-fails-unknown-column-entity-modified-date
Workaround
A workaround is to upgrade to CiviCRM 5.44 first and then to CiviCRM 5.45. This fixed the problem for me with this particular site.