Implement the drush migrate-fields-destination command, to list available fields on the migration destination. D7 example:

$ drush mfd beerterm

beerterm Destination Fields

 Existing term ID            tid         
 Name                        name        
 Description                 description 
 Parent (by Drupal term ID)  parent      
 Parent (by name)            parent_name 
 Format                      format      
 Weight                      weight      
 Path alias                  path
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeryan created an issue. See original summary.

mikeryan’s picture

Status: Active » Postponed
Related issues: +#2630732: Implement Entity::fields() for migration destinations

For this to work for entity destinations, we need #2630732: Implement Entity::fields() for migration destinations.

mikeryan’s picture

Version: 8.x-1.x-dev » 8.x-4.x-dev
Status: Postponed » Active

We could do this anyway, just make sure we do an is_array() on the fields() return for safety.

joachim’s picture

Status: Active » Needs work
FileSize
1.67 KB

Here's that implemented as a Drush 8 command.

The Drush 9 version will need doing -- I'm not yet using Drush 9 on my project.

Eli-T’s picture

@joachim I was going to port this command to Drush 9 but when I tested it on Drush 8.1.16 with Drupal 8.4.4 I couldn't get any output.

I have a set of basic migrations using a plugin source that extends Drupal\migrate\Plugin\migrate\source\SqlBase and migrates to a custom node type that has standard title and body fields, plus a couple of entity references. This migration runs fine and the fields on the custom content type are correctly populated

However, running the command from the patch in #4 gives no output.
I know the command is running, because if I specify a non-existent migration id, I get the expected error message.

╭─vagrant@imdbvm [11:26:58 AM]  /var/www/drupalvm/drupal84/web  ‹master*›
╰─➤  drush migrate-fields-destination monkey_node;

╭─vagrant@imdbvm [11:30:04 AM]  /var/www/drupalvm/drupal84/web  ‹master*›
╰─➤  drush migrate-fields-destination monkey_node_nonsense_name;
Migration monkey_node_nonsense_name does not exist

It looks like $destination = $migration->getDestinationPlugin(); produces a valid instance of Drupal\migrate\Plugin\migrate\destination\EntityContentBase but $destination->fields() returns NULL.

Am I missing something or is there a problem with this approach?

Eli-T’s picture

Sorry, here's the config for the migration in question:

#Migration configuration for monkeys
id: monkey_node
label: Simians from the IMDB
migration_group: imdb
source:
  plugin: migrate_monkey_nodes
destination:
  plugin: entity:node
process:
  type:
    plugin: default_value
    default_value: monkey
  title: name
  body: description
  field_favourite_tree:
    plugin: migration_lookup
    migration: tree_node
    source: favourite_tree_id
  field_best_friend:
    plugin: migration_lookup
    migration: monkey_node
    source: best_friend_id
migration_dependencies:
  required:
    - tree_node
dependencies:
  enforced:
    module:
      - migrate_monkeys
joachim’s picture

> It looks like $destination = $migration->getDestinationPlugin(); produces a valid instance of Drupal\migrate\Plugin\migrate\destination\EntityContentBase but $destination->fields() returns NULL.

You need the core patch from #2630732: Implement Entity::fields() for migration destinations.

heddn’s picture

Status: Needs work » Postponed

This should be postponed then.

joachim’s picture

joachim’s picture

Rerolled for the 5.x branch -- there's no more old style Drush command.