Hi

I'm in the need of doing some extra actions after a site is migrated from one platform to another, and I've managed to get some actions done BEFORE migrating the site, using a drush .inc file & pre_provision_migrate hook, but I'm not being able to "inject" code after the database is loaded in the new platform, I've tried provision_migrate & provision_migrate_validate but both hooks are ran before the dump load.
I've also tried post_provision_migrate but somehow it appears like it is not applied at all and I'm not able to modify anything in the db.

Could you tell me which hook should I use or point me to some documentation?

My file currently is like this:

function drush_mymodule_pre_provision_migrate($url = NULL) {
  drush_log(dt("description before dump")); 
  drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_DATABASE);
  db_query("blablablah");
}

function drush_antiviews_post_provision_migrate($url = NULL) {
  drush_log(dt("after dump load ?"));
  drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_DATABASE);
  db_query("blablablah");
}

First function works ok, second not.

I'm using aegir 0.4-alpha7, not sure of the version of provision

Any help is appreciated! thank you!

Comments

Anonymous’s picture

Just some ideas below -

the Migrate task invokes 'provision-deploy' which fully bootstraps the new site after importing the new database from the backup.

So your post hook might be best placed in a drush_antiviews_drupal_post_provision_deploy() while the database is bootstrapped

Look at drush_provision_drupal_post_provision_deploy and you can see it does a call to 'drush_include_engine('drupal', 'deploy') - wherein the /var/aegir/.drush/provision/platform/drupal/deploy.inc is included, and you can see some queries that we do there after the new database is connected, primarily to fix up some paths related to the old site location/name.

You may want to do a similar thing in your case, by having a 'drupal' subdirectory in your antiviews extension with a 'deploy.inc' (for Drupal 6 - you can have a deploy_5.inc and deploy_7.inc for other versions of Drupal like we do in Provision), and a call to drush_include_engine in a post_provision_deploy hook.

There may be a better way to do this, i'm not sure..

pcambra’s picture

Hi mig5, thanks for the reply!

I've followed this guide for getting my script called http://scotthadfield.ca/2010/06/28/hooking-drush-and-aegir and what I have is a single file in .drush folder called antiviews.drush.inc with the contents above, no "extra drush module".

I've tried to follow your suggestions but when I execute a migrate, the function drush_antiviews_drupal_post_provision_deploy doesn't get called, or at least the drush_log is not in the aegir logs.

Maybe I have to have a complete module and create a deploy.mymodule.inc to get the drupal_post_provision_deploy actually called?

Anonymous’s picture

Status: Active » Postponed (maintainer needs more info)

I think it should be 'drush_antiviews_post_provision_deploy'.

Report back if this works or if you figured it out.

Also read my recent article which does a similar thing (but on install, not deploy)

http://www.migueljacq.com/content/developing-aegir-extending-aegir-and-c...

attiks’s picture

I posted a patch in #881496: Problem migrating sites with mysql views, to fix it, but it probably needs some reviewing

attiks’s picture

double post

Anonymous’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Closing old support ticket