4

I'd like to run the database upgrades from the command line. I know I can do with with drush civicrm-upgrade-db but I'd like to know a way to do it in a CMS-agnostic way (that will work for Wordpress and Joomla).

I see there is cv ext:upgrade-db which claims to "Apply DB upgrades for any extensions". Is there a corresponding cv command for CiviCRM core?

2

The cv upgrade:db command from https://github.com/civicrm/cv/pull/2 was recently merged for v0.2.3. This revision hasn't been broadly deployed or tested yet, but it provides a richer upgrade experience:

  • By default, there's a progress indicator.
  • With -vvv, you can get a detailed report/log of the upgrade steps as they execute.
  • With -vvv --dry-run, you can see a detailed preview of the upgrade steps.
  • With --retry or --skip, you can resume after an upgrade failure.
  • With --quiet, you can limit output to particularly interesting information.

I've found that -vvv and --dry-run are helpful when developing patches for the civicrm-core upgrade logic, and they may also be helpful with large or temperamental upgrades.

(Note: PR #2 also anticipates several more subcommands for identifying/downloading upgrades and for reporting successes and failures. However, these are not live at time of writing)

2

That would be nice, but I am afraid it is not there (yet). When you lookup the list of cv commands in de source on GitHub, you will not find this command.

However, using the drush source code as inspiration you can create a small script

<?php
  $codeVer = CRM_Utils_System::version();
  $dbVer = CRM_Core_BAO_Domain::version();
  if (version_compare($codeVer, $dbVer) == 0) {
     echo "You are already upgraded to CiviCRM $codeVer \n";
  } else {
     $upgradeHeadless = new CRM_Upgrade_Headless();
     $result = $upgradeHeadless->run();
     echo "Upgrade outputs:\n" . $result['text'] . "\n";
  }

And run it with the cv scr <script.php>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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