Skip to content

Instantly share code, notes, and snippets.

@angry-dan
Created November 27, 2014 10:27
Show Gist options
  • Select an option

  • Save angry-dan/d3975b8abb5ee515db3f to your computer and use it in GitHub Desktop.

Select an option

Save angry-dan/d3975b8abb5ee515db3f to your computer and use it in GitHub Desktop.

If you ever need to run an update hook again with drush you can often do this:

drush eval "module_load_instal('module_name'); module_name_update_7012();"

But! If that update is run as a batch then that won't work. So instead you can do this:

drush eval "drupal_set_installed_schema_version('module_name', '7011');"
drush updb

Which effectively rolls the module back to it's old version number.

Now, that saves you faffing about in the DB.

@JamesWilmot
Copy link

Hi Dan!

Very useful. Neatly solves a problem that I was having.

I would like to run a few thoughts past you, if I may.

Problem:

  • best practise: configuring db state in smallest update hooks possible (ie no update hooks doing stupid amounts of stuff.)
  • might do a fair amount of development before getting into environment for first time (ala prod)
  • initial install doesn't run update hooks
  • prefer not to write a hook_install for each module that runs all the hook_updates (or maybe this is something I should be doing?)

My solution in an install.sh script:

drush si profile
drush en sitename_core
drush en sitename_someotherfeature
drush eval "drupal_set_installed_schema_version('sitename_core', '7000');"
drush eval "drupal_set_installed_schema_version('sitename_someotherfeature', '7000');"
drush updb -y

Thoughts? Or is there another way to skin this cat?

Thanks heaps!

James

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment