Created
November 5, 2021 14:17
-
-
Save vladdancer/5b60cdc2c4b2a8e7db5f85052874a4a9 to your computer and use it in GitHub Desktop.
Recreate migrate map tables for specific migration #migrate #drupal8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* recreateMigrationMapTables.drush.php | |
* | |
* Usage: | |
* @code | |
* drush scr recreateMigrationMapTables.drush.php [MIGRATION_ID] | |
* @endcode | |
*/ | |
$migrationId = $extra[0] ?? NULL; | |
if (empty($migrationId)) { | |
print "You should provide 'migration_id' argument\n"; | |
return; | |
} | |
$migration = \Drupal::service('plugin.manager.migration') | |
->createInstance($migrationId); | |
$idMapConfiguration = []; | |
/** @var \Drupal\migrate\Plugin\migrate\id_map\Sql $idMap */ | |
$idMap = \Drupal::service('plugin.manager.migrate.id_map') | |
->createInstance('sql', $idMapConfiguration, $migration); | |
// Invoke $idMap->ensureTables() via: | |
$idMap->getDatabase(); | |
print "Migration map tables recreated for $migrationId\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment