PHP Fatal Error: Upgrading from 6.0.0(3) to 7.0.2 Stuck

Situation
I am upgrading from 6.0.0(3) to 7.0.2 I followed the prescribed upgrade steps provided here Linux Upgrade 7.0.1 to 7.0.2 - OpenEMR Project Wiki & at step 6 to upgrade SQL, Updating UUIDs (this could take some time) has taken over 4 hours now.

Looked through the logs & saw these 2 errors

[Sat Jun 08 2024] [proxy_fcgi:error] [pid 2379] [client 192.0.1.130:42552] AH01071: Got error 'PHP message: OpenEMR CSRF token authentication error', referer: http://192.0.1.15/openemr/sql_upgrade.php
[Sat Jun 08 2024] [proxy_fcgi:error] [pid 2378] [client 192.0.1.130:42551] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught OpenEMR\\Common\\Database\\SqlQueryException: Failed to execute statement. Error: Invalid default value for 'modified_date' Statement: SELECT count(*) AS cnt FROM `patient_history` WHERE `uuid` IS NULL OR `uuid` = '' OR `uuid` = '\n  thrown in /var/www/html/openemr/src/Common/Database/QueryUtils.php on line 46', referer: http://192.0.1.15/openemr/sql_upgrade.php

Upgrade is now stuck for hours. Not sure what else to look at.

OpenEMR Version
I’m using OpenEMR version 6.0.0(3)

Browser:
I’m using: Chrome 125.0.6422.112

Operating System
I’m using: CentOS Linux 7.9.2009

Search
Did you search the forum for similar questions? Yes

Logs
Did you check the logs? Yes
Was there anything pertinent in them? Yes, shared above.

[Sat Jun 08 2024] [proxy_fcgi:error] [pid 2379] [client 192.0.1.130:42552] AH01071: Got error 'PHP message: OpenEMR CSRF token authentication error', referer: http://192.0.1.15/openemr/sql_upgrade.php
[Sat Jun 08 2024] [proxy_fcgi:error] [pid 2378] [client 192.0.1.130:42551] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught OpenEMR\\Common\\Database\\SqlQueryException: Failed to execute statement. Error: Invalid default value for 'modified_date' Statement: SELECT count(*) AS cnt FROM `patient_history` WHERE `uuid` IS NULL OR `uuid` = '' OR `uuid` = '\n  thrown in /var/www/html/openemr/src/Common/Database/QueryUtils.php on line 46', referer: http://192.0.1.15/openemr/sql_upgrade.php

Upgrade Progress Details Errors

CREATE TABLE `patient_history` ( `id` BIGINT(20) NOT NULL AUTO_INCREMENT , `uuid` BINARY(16) NULL , `date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP , `care_team_provider` TEXT , `care_team_facility` TEXT , `pid` BIGINT(20) NOT NULL , PRIMARY KEY (`id`) , UNIQUE `uuid` (`uuid`)) ENGINE = InnoDB

The above statement failed: Invalid default value for 'date'
CREATE TABLE `jwt_grant_history` ( `id` INT NOT NULL AUTO_INCREMENT , `jti` VARCHAR(100) NOT NULL COMMENT 'Unique JWT id' , `client_id` VARCHAR(80) NOT NULL COMMENT 'FK oauth2_clients.client_id' , `jti_exp` TIMESTAMP NULL DEFAULT NULL COMMENT 'jwt exp claim when the jwt expires' , `creation_date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'datetime the grant authorization was requested' , PRIMARY KEY (`id`) , KEY `jti` (`jti`)) ENGINE = InnoDB COMMENT = 'Holds JWT authorization grant ids to prevent replay attacks'

The above statement failed: Invalid default value for 'creation_date'
CREATE TABLE `document_templates` ( `id` bigint(21) UNSIGNED NOT NULL, `pid` bigint(20) DEFAULT NULL, `provider` int(11) UNSIGNED DEFAULT NULL, `encounter` int(11) UNSIGNED DEFAULT NULL, `modified_date` datetime NOT NULL DEFAULT current_timestamp(), `profile` varchar(31) DEFAULT NULL, `category` varchar(63) DEFAULT NULL, `location` varchar(255) DEFAULT NULL, `template_name` varchar(255) DEFAULT NULL, `status` varchar(31) DEFAULT NULL, `exclude_portal` tinyint(1) NOT NULL DEFAULT 0, `exclude_dashboard` tinyint(1) UNSIGNED NOT NULL DEFAULT 0, `size` int(11) NOT NULL DEFAULT 0, `template_content` mediumblob DEFAULT NULL, `mime` varchar(31) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `location` (`pid`,`category`,`template_name`,`status`)) ENGINE=InnoDB

The above statement failed: Invalid default value for 'modified_date'
CREATE TABLE `document_template_profiles` ( `id` bigint(21) UNSIGNED NOT NULL AUTO_INCREMENT, `template_id` bigint(21) UNSIGNED NOT NULL, `profile` varchar(64) DEFAULT NULL, `template_name` varchar(255) DEFAULT NULL, `category` varchar(63) DEFAULT NULL, `provider` int(11) UNSIGNED DEFAULT NULL, `modified_date` datetime NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `location` (`profile`,`template_name`,`template_id`)) ENGINE=InnoDB

The above statement failed: Invalid default value for 'modified_date'

You can also turn on User Debugging under Administration->Globals->Logging User Debugging Options=>All

Tell me about your database.

Running on MariaDB version 5.5.68

Yeah, thought so. The commands that are failing are failing because 5.5 doesn’t support CURRENT_TIMESTAMP on date fields. You need a database upgrade – although I have no idea how the OpenEMR upgrade process will handle an upgrade that had to be stopped in the middle.

2 Likes

@Benzo
You don’t need to be concerned with the upgrade failing then starting again using a new sequel engine. Just be happy Asher caught the version deficiency or we’d been chasing our tail!:slight_smile:
I hope you’ve done due diligence and backed up. If not, do so.

Upgrading to a new sequel engine version can cause issue if not careful however it’s been awhile since I’ve done one. Investigate on the web first.

1 Like

Updates can be safely retried if they fail? That’s very good to know – thanks!

Awesome gents.

I have upgraded MariaDB & Restart sql_upgrade. Will let you know shortly if it’s successful.

Upgrade done. Thanks once again.