How to run custom code on rollback? I have write a migration class to enter the value in custom table. But I want to know that how to rollback custom table entry.

I used :

public function complete($entity, stdClass $row) {
  // db_insert in my custom table
}


I want to rollback the above changes. For this I tried the completeRollback method below but it is not working.

public function completeRollback($entity_id) {
  dsm($entity_id);
}
You want to use prepareRollback() because at that point the thing that you are rolling back has not been removed yet.

public function prepareRollback($entity_id) {
  parent::prepareRollback();
  // Code to execute before an entity has been rolled back
}


Take a look at this guide for more info.