Answers.Body: <p>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 <a href="https://github.com/civicrm/cv" rel="nofollow noreferrer">cv</a> installed.</p>
  <pre><code>cv upgrade:db -vvv
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-21T03:28:42.983Z
Answers.Text: 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 :)
Answers.UserDisplayName: jenlampton
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-21T03:10:15.180Z
Answers.LastActivityDate: 2022-09-21T03:27:42.747Z
Answers.LastEditDate: 2022-09-21T03:27:42.747Z
Answers.UserDisplayName: Andy Burns
Body: <p>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.</p>
  <p>The &quot;CiviCRM System Status&quot; page has a row that reads &quot;New codebase version detected. You must visit upgrade screen to upgrade the database&quot;  but if I click the &quot;visit upgrade&quot; link, the resulting page still says &quot;DB Error: unknown error&quot;.</p>
  <p>As far as I can tell from the logs, it looks like the fatal errors are
  caused by <code>CRM_Upgrade_Incremental_MessageTemplates-&gt;updateTemplates()</code>, and seems
  to be coming from a database query that looks something like <code>&quot;UPDATE civicrm_msg_template SET msg_html = '...' &quot;</code></p>
  <p>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!</p>
  <p>I can successfully run the update using the command <code>drush civicrm-upgrade-db</code> 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.</p>
  <p>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?</p>
  <p>For reference:</p>
  <ul>
  <li>old civi version is 5.47.3</li>
  <li>new civi version is 5.53.0</li>
  <li>CMS is Backdrop CMS</li>
  </ul>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-21T11:37:38.073Z
Comments.Text: Try this https://civicrm.stackexchange.com/posts/comments/46707?noredirect=1. A search on the error might have revealed that possible solution.
Comments.UserDisplayName: thoni56
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-22T02:57:18.453Z
Comments.Text: Do you have a full stacktrace in the log?
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-22T17:04:37.270Z
Comments.Text: @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)
Comments.UserDisplayName: jenlampton
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-22T17:12:48.300Z
Comments.Text: @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.
Comments.UserDisplayName: jenlampton
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-22T18:39:36.583Z
Comments.Text: 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.
Comments.UserDisplayName: Demerit
Tags: <upgrade><backdrop>
Title: Unable to run civi database upgrades through UI
ThreadText: # Unable to run civi database upgrades through UI
  
  (Asked by: username_0 on 2022-09-21)
  
  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
  
  **Tags:** upgrade, backdrop
  
  > **Comments:**
  > **username_1**: Try this https://civicrm.stackexchange.com/posts/comments/46707?noredirect=1. A search on the error might have revealed that possible solution.  
  > **username_2**: Do you have a full stacktrace in the log?  
  > **username_0**: @username_1 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)  
  > **username_0**: @username_2 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.  
  > **username_2**: 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.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2022-09-21. Score: 2
  
  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](https://github.com/civicrm/cv) installed.
  
  ```
  cv upgrade:db -vvv
  
  ```
  
  > **Comments:**
  > **username_0**: 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 :)  
  
  ---
  
  