You are here

public static function MigrateGroup::deleteOrphans in Migrate 7.2

Remove any groups which no longer contain any migrations.

1 call to MigrateGroup::deleteOrphans()
MigrationBase::deregisterMigration in includes/base.inc
Deregister a migration - remove all traces of it from the database (without touching any content which was created by this migration).

File

includes/group.inc, line 196
Definition for a migration group.

Class

MigrateGroup
@file Definition for a migration group.

Code

public static function deleteOrphans() {
  $query = db_select('migrate_group', 'mg');
  $query
    ->addField('mg', 'name');
  $query
    ->leftJoin('migrate_status', 'ms', 'mg.name=ms.group_name');
  $query
    ->isNull('ms.machine_name');
  $result = $query
    ->execute();
  foreach ($result as $row) {
    db_delete('migrate_group')
      ->condition('name', $row->name)
      ->execute();
  }
}