I have some modules in 8.8.5 that need an major update. What is the best practice without loosing data or settings?

For example: drupal/admin_toolbar 1.27.0 2.2.0

  • Do I need to uninstall the module in de admin backoffice Drupal?
  • If so, I first need to uninstall both modules: Required by: admin_toolbar_tools, adminimal_admin_toolbar
  • Finally uninstall admin_toolbar
  • Composer remove drupal/admin_toolbar
  • Composer require drupal/admin_toobar
  • Drush updatedb
  • Drush cr

Is that the correct way? Or can I simply remove the old version with composer and require the new one?

  • 2
    composer update is the simpler way, if there aren't issues with updating the other modules. Once the code is updated, you can visit update.php, after being sure you are logged in as administrator.
    – apaderno
    Commented May 11, 2020 at 13:33

1 Answer 1


No you don't uninstall the module first. You want to have the module enabled when updating to let possible database updates kick in. Which may be performed to update existing data/entities. If you already have the latest 1.x version installed you could simply do

  1. $ composer require drupal/admin_toolbar to upgrade the module.
  2. $ drush cr && drush -y updb to perform database updates.
  3. And finally $ drush -y cex to export any eventually updated config.

If you don't have the latest 1.x version installed yet, it's better to upgrade incrementally. And to play really safe to also do two consecutive releases for that.

  1. $ composer update drupal/admin_toolbar --with-dependencies && drush cr && drush -y updb && drush -y cex to first update to the latest 1.x version, followed by a release.
  2. And then $ composer require drupal/admin_toolbar && drush cr && drush -y updb && drush -y cex to get the latest major upgrade, followed by another release.
  • Let us continue this discussion in chat.
    – leymannx
    Commented May 12, 2020 at 14:11
  • @ anyone why do we need --with-dependencies for composer update but not for composer require ?
    – Juc1
    Commented Dec 18, 2022 at 9:42
  • @Juc1 – For the require command it's --update-with-dependencies or --update-with-all-dependencies. Sounds clever to use that combination. Try it out and let us know.
    – leymannx
    Commented Dec 18, 2022 at 11:02

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.