civicrm / cv

CiviCRM CLI Utility
28 stars 30 forks source link

Combine "upgrade:db" and "ext:upgrade-db". Support "updb" alias. #200

Closed totten closed 5 months ago

totten commented 5 months ago

Before

After

Screenshot 2024-06-21 at 6 36 12 PM

Comments

The traditional command upgrade:db has been more featureful -- it provides progress-indicators, verbose output, and resume/skip options... but ext:upgrade-db had none of these. With the combined command, these features are available in both contexts.

colemanw commented 5 months ago

This looks good, although I find the difference between "auto" and "full" to be a bit confusing. Both modes will upgrade everything, so is there really a need for the distinction?

totten commented 5 months ago

Cool. Glad it's merged.

... find the difference between "auto" and "full" to be a bit confusing ...

Yeah, unfortunately, the pre-existing protocols for CRM_Upgrade_Form and CRM_Extension_Upgrades don't do what one wants for a unified cv updb. (There's disagreement on whether to proceed with execution when the DB/code versions already match. CRM_Upgrade_Form protocol says to quit -- but cv updb should continue with extension-upgrades.)

The mismatch means that some messiness is going to show up somehow. The $mode is just a way to organize that bit of mess. The options are distinguished as:

  1. auto (normal): Do what a user actually expects from a unified DB upgrade command. (Upgrade core and/or extension, depending on what's pending.)
  2. full: Follow the pre-existing protocol for CRM_Upgrade_Form (as currently understood circa 5.74; with an extra compatibility step for <5.53).
  3. ext: Follow the pre-existing protocol for CRM_Extension_Upgrades (as currently understood circa 5.74)

Binding $mode to --mode (with a default auto) reflects an attitude favoring transparency. ("If $mode has to exist, and if it makes a big difference in how the thing behaves, then $mode should probably be visible/hackable.)