Created
April 28, 2023 14:25
-
-
Save vladdancer/23acfa52d32265f9e36b8fa50b8f7096 to your computer and use it in GitHub Desktop.
recreateMigrationMapTables #drupal #drush
This file contains hidden or 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 | |
* | |
* Ensure that migrate_map_* table is created for a given migration. | |
* | |
* Usage: drush scr ./recreateMigrationMapTables.drush.php migrate_users | |
* | |
* @code | |
* drush src recreateMigrationMapTables.drush.php [MIGRATION_ID] | |
* @endcode | |
*/ | |
declare(strict_types=1); | |
$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 = []; | |
/** | |
* The id_map plugin. | |
* | |
* @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