12

I create migration script with migrate_upgrade module, but i have a lot of ignored items while migration, i tried to use drush mmsg from migrate tools but its not help with ignored fields only with failed.

4 Answers 4

9

Once you've identified the row, as described above, it's sometimes still hard to find. My case it was triggering updates on a previously imported entity, which was then throwing a row skip exception.

You can work out what is throwing the exception by watching the while($source->valid()) loop in MigrateExecutable::import(). It's around line 198 (at the moment). There it has a try-catch which will catch exceptions telling it to skip the row.

If you have a debugger set a watch for your skipped ID and then get the line and file triggering it from the exception.

If you don't, it's worth getting one, but you can add an if based on the sourceIdValues and print the $e->getLine() $e->getFile() to get where the exception was thrown.

1
  • 2
    In my case it was a static_map plugin which was wrong. The while loop you said is now around line 198 of MigrateExecutable.php. Using some \Drupal::logger calls with $e->getLine and $e->getFile did the trick for me to find out what was going on. Many thanks!
    – Roger
    Commented Feb 16, 2017 at 15:28
7

I'm not sure if there's a "more proper" way to investigate what's going on with individual migration jobs, but I just view my migrate_* database tables. It doesn't tell me the reason why a specific row failed, but at least I'll be able to identify exactly which ones I need to investigate.

In the migrate_* table that matches the migration job that you're interested in, look for lines where the destid1 value is NULL.

6

You are migrating from Drupal 7 to Drupal 8 and you have ignored items after you run a migration. This leads to the very important question of which ones were ignored?

What you see

[notice] Processed 632 items (630 created, 0 updated, 0 failed, 2 ignored) - done with 'node_form'

The above is what I will use in my examples.

What you want to know

What are the items ignored!? For this we can look into the database. I assume you have access to a console...

The migrate_map_migration_name table in your database will give you the information you need. There will be a column named source_row_status. The value of 2 equals the status of ignored. So run the following MySQL command:

SELECT * FROM `migrate_map_node_form` WHERE source_row_status = 2;

The sourceid1 column of the returned rows will contain the id of the item that was ignored.

Example output:

+-------------------------------------------------------+-----------+---------+-------------------+-------------------+---------------+------+
| source_ids_hash                                       | sourceid1 | destid1 | source_row_status | source_row_status | last_imported | hash |
+-------------------------------------------------------+-----------+---------+-------------------+-------------------+---------------+------+
| 8530eb5d63ad4cfea47134a28e3339e089f639164d218287c3... | 10931     | NULL    | 2                 | 0                 | 0             |      |
+-------------------------------------------------------+-----------+---------+-------------------+-------------------+---------------+------+
| ddd550e747c2a26a2a5058d49be0e146616fd5c45f6bef88f3... | 11656     | NULL    | 2                 | 0                 | 0             |      |
+-------------------------------------------------------+-----------+---------+-------------------+-------------------+---------------+------+
1

My preference is to use xdebug and PHP exception breakpoints to explore what's happening when various migrate exceptions are thrown. I use PHPStorm so I use the Run > View Breakpoints menu item to pull up the breakpoints window. I then add the following PHP Breakpoints:

  1. Drupal\migrate\MigrateException
  2. Drupal\migrate\MigrateSkipRowException (the most useful for ignored rows)
  3. Drupal\migrate\MigrateSkipProcessException

I then execute the migration (before this, you have to be sure PHPStorm is listening and correctly working with xdebug for breakpoints and whatnot). When one of these exceptions is thrown PHPStorm stops the call. I use the Frames window to browse the call stack, looking through the variables over time. This makes it easy to identify the field, and the data (source, destination, row, etc.) at each step of the way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.