starterkit-drupalsite
starterkit-drupalsite copied to clipboard
Make it easier to deploy removal of modules which have associated entities
Modules such as shortcut install starter data, so they're hard to remove.
To reproduce:
- ./scripts/deploy.sh
- ./scripts/ssh.sh
- drush pmu shortcut (this gives an error)
- drush entity:delete shortcut
- drush pmu shortcut (now this works)
- exit
- ./scripts/export-config.sh
- ./scripts/destroy.sh
- ./scripts/deploy.sh
This will fail with the very ugly error:
[error] Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization.
Entities exist of type <em class="placeholder">Shortcut link</em> and <em class="placeholder">Shortcut set</em> <em class="placeholder">Default</em>. These entities need to be deleted before importing. in Drupal\Core\Config\ConfigImporter->validate() (line 748 of /var/www/html/core/lib/Drupal/Core/Config/ConfigImporter.php).
In ConfigImportCommands.php line 357:
The import failed due to the following reasons:
Entities exist of type <em class="placeholder">Shortcut link</em> and <em c
lass="placeholder">Shortcut set</em> <em class="placeholder">Default</em>.
These entities need to be deleted before importing.
config:import [--preview [PREVIEW]] [--source SOURCE] [--partial] [--diff] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--notify [NOTIFY]] [--druplicon] [--xh-link XH-LINK] [--] <command> [<label>]
This actually is sensible: it's refusing to delete data (in this case shortcuts in the starter database).
There are a few workarounds:
- option 1: go to the uninstall page of the GUI and follow the link to remove the offending entities
- option 2: remove the entities with drush: drush entity:delete shortcut
- option 3: drush ev '\Drupal::EntityTypeManager()->getStorage("shortcut_set")->load("default")->delete();'
- option 4: update the starter database once you removed the offending entities. (./scripts/update-starter-data.sh)
In some cases (as with "shortcut") you don't really care about the entities, so you could delete them in ./drupal/scripts/update.sh, however running "drush entity:delete shortcut" is not idempotent: it will fail if there are no such entities.
In this ticket, it would be nice to document a way to document how to uninstall modules whose entities we do not care about, and make deployment seamless.