Last updated May 4, 2012. Created by bleedev on November 16, 2011.
Edited by twom, mikeryan, dale42, mgifford. Log in to edit this page.
pre/post Import/Rollback methods
You can execute code before or after an import or rollback operation by implementing the Migration class methods preImport(), postImport(), preRollback(), or postRollback(). Each of these is called once per individual Migration - that is, if you implement preImport() in an article node migration class, it will be called after any previous migrations you've defined, and immediately before the first row of your article node migration is called.
Typical actions can be the enabling / disabling of certain modules or changing configurations.
<?php
class ArticleMigration implements Migration {
...
public function preImport() {
parent::preImport();
// Code to execute before first article row is imported
}
...
public function postImport() {
parent::postImport();
// Code to execute after the last article row has been imported
}
...
public function preRollback() {
parent::preRollback();
// Code to execute before first article row is deleted
}
...
public function postRollback() {
parent::postRollback();
// Code to execute after the last article row has been deleted
}
?>A practical example can be found here.
NOTE: If you are running your migrations through the web UI, which chunks the work into batches, if a given migration takes long enough to be broken into separate batches, these functions will be called for each batch.