reinstall.install 917 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * @file
  4. * Reinstall install file.
  5. */
  6. /**
  7. * Remove migration tables.
  8. *
  9. * @param string $table
  10. * The base name of the table to drop.
  11. */
  12. function reinstall_remove_migration_tables($table) {
  13. $db = \Drupal::database();
  14. $logger = \Drupal::logger('reinstall');
  15. $db->schema()->dropTable('migrate_map_' . $table);
  16. $logger->notice('Table migrate_map_@table dropped', [
  17. '@table' => $table,
  18. ]);
  19. $db->schema()->dropTable('migrate_message_' . $table);
  20. $logger->notice('Table migrate_message_@table dropped', [
  21. '@table' => $table,
  22. ]);
  23. }
  24. /**
  25. * Implements hook_uninstall().
  26. */
  27. function reinstall_uninstall() {
  28. // Get all migrations.
  29. $manager = \Drupal::service('plugin.manager.config_entity_migration');
  30. $plugins = $manager->createInstances([]);
  31. // Remove migration tables.
  32. foreach ($plugins as $migration) {
  33. reinstall_remove_migration_tables($migration->id());
  34. }
  35. }