I would very much like to upgrade my version of civi to the latest secure version, but every time I attempt to do so I get stuck at the section of running the database update.

The "CiviCRM System Status" page has a row that reads "New codebase version detected. You must visit upgrade screen to upgrade the database" but if I click the "visit upgrade" link, the resulting page still says "DB Error: unknown error".

As far as I can tell from the logs, it looks like the fatal errors are caused by CRM_Upgrade_Incremental_MessageTemplates->updateTemplates(), and seems to be coming from a database query that looks something like "UPDATE civicrm_msg_template SET msg_html = '...' "

I haven't actually succeeded in loading the update page, let alone started running the update, so I'm not sure why it looks like the update is running (and failing?) but even so - I do eventually need it to be able to run!

I can successfully run the update using the command drush civicrm-upgrade-db but since I don't have drush installed on my production server, I will never be able to update my production site if we can't figure out what's wrong with the UI, or find another way to run the updates.

A thought: Most CMSes already have a robust system for running updates. I don't know why civi isn't using that already, but since the civi UI is broken, I wonder if it would be possible to use the working system update UI to trigger the civicrm database updates? Has anyone tried to write update hooks that trigger civi updates?

For reference:

  • old civi version is 5.47.3
  • new civi version is 5.53.0
  • CMS is Backdrop CMS
  • Try this civicrm.stackexchange.com/posts/comments/46707?noredirect=1. A search on the error might have revealed that possible solution.
    – thoni56
    Sep 21, 2022 at 11:37
  • Do you have a full stacktrace in the log?
    – Demerit
    Sep 22, 2022 at 2:57
  • @thoni56 I did a search on the error, and several permutations of it. Nothing similar came back. I wouldn't have posted if I'd found anything relevant. (The recommended link was not only for Joomla!, but also for a completely different error)
    – jenlampton
    Sep 22, 2022 at 17:04
  • @Demerit Yes, I did have a full stacktrace in the log, that's how I was able to determine that the problem started with CRM_Upgrade_Incremental_MessageTemplates->updateTemplates(). I went to see if I could copy/paste it into the Original Post but I've cleared out the logs since then. If it would be helpful I can reimport the live database and generate it again.
    – jenlampton
    Sep 22, 2022 at 17:12
  • 1
    Usually the full log has the actual mysql error in it just maybe buried a bit. If you are going to reload the database, then before the upgrade, you can visit administer - system settings - debugging and turn on backtrace, and then the full log will also show on screen if it fails. Also if reloading, be sure to drop the whole db first - 5.48 creates a table that won't be included in the DROP TABLE statements from a 5.47 backup, so its presence will lead to different errors on a re-run.
    – Demerit
    Sep 22, 2022 at 18:39

1 Answer 1


I've experienced issues occasionally upgrading the database in the UI but succeeding in command line for the same upgrade so you could try that route if you have cv installed.

cv upgrade:db -vvv
  • Unfortunately I can't install drush or cv on the production server at the moment. If I can't figure out what's wrong with the UI we may need to open a ticket with the hosting company and beg :)
    – jenlampton
    Sep 21, 2022 at 3:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.