reinstall.install 826 B

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