The one missing piece now to the beer example is a demonstration of image migration. Since this will be the first introduction to D8 migration development for many, it's important to start off with best practices, so unlike the D7 version we'll show how to migrate files in a separate migration, referenced by the node migration.

Comments

mikeryan created an issue. See original summary.

charginghawk’s picture

mikeryan - while waiting for this issue to be resolved, can you quickly describe what best practices should be for image migration?

I'm working with image migration right now, and even a brief outline of the procedure would be very helpful in the interim.

mikeryan’s picture

Best practice in general is to migrate file assets in their own migration and reference them (with the migration process plugin) from any other entity that needs them. To my mind, creating entities as side-effects of migrations rather than explicitly in their own migration is problematic on multiple counts

  1. Anything complex enough to require its own entity type is complex enough to separate its mappings from those of referring entities.
  2. The mappings of subfields (the referenced entity's fields) within a larger entity complicates things, and makes debugging harder.
  3. Entities created as side-effects aren't tracked as top-level migrated entities are via the map tables - it's harder to tell where they came from, and in most cases they won't get deleted when the parent entity is rolled back.
ressa’s picture

Has an example been included yet in the beer example?

mikeryan’s picture

No, this issue is still open.

mikeryan’s picture

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

Actually, let's wait until #2695297: Refactor EntityFile and use process plugins instead is done, and add this in the 8.2.x-compatible branch of migrate_plus once that's opened.

mikeryan’s picture

moshe weitzman’s picture

youfei.sun’s picture

Any updates on this issue please?

ressa’s picture

It would be really great with a working example of how to import an image. There is part of an example in #2635622: Process plugin for importing/creating files by URL, but I can't quite figure out how to piece it all together...

mikeryan’s picture

Status: Postponed » Active

The EntityFile patch is in core 8.2.x, so we'll be able to address this once I open the 8.x-3.x branch supporting 8.2.x and up.

ressa’s picture

Fantastic, I look forward to that release, thanks!

nicrodgers’s picture

Does anyone have any working config/code examples for migrating an image in to 8.2.x? I can't seem to find anything :(

maijs’s picture

@nicrodgers, try migrate_source_example module (8.2.x branch). Take a look at migration example from CSV files, it has been updated to work with Drupal 8.2.

youfei.sun’s picture

I think #14 is not helping, any hints on that?

p.s. looking at those files, i did have step through a bit, but I can't make the file_copy plugin right or there is some other issues,
all my attempts for migrating a single file entity failed with no detailed information, a clear beer example for migrating file entity would be optimal

youfei.sun’s picture

From #6 , what I get is that from drupal 8.2.x we can use something like

user_picture:
    -
      plugin: default_value
      default_value:
        - /Users/youfei/youfei.jpg
        - public://youfei.jpg
    -
      plugin: file_copy
    -
      plugin: entity_generate

for an file entity, but this did not work in my case, did I miss anything in that thread?