I am using the Migrate module for a D7 to D8 migration and I am writing the whole migration manually in code (rather than use the built in D7 migrate module, as I wanted more granual control on the migration.)
I have the following structure: the D7 site has a image field where images are stored as File entities. On the D8 site, the image field is an entity reference to a Media entity (and the Media entity in turn has a Image field.)
Originally, I had the following for my Images migration:
id: image_files
source:
plugin: legacy_images
constants:
source_base_path: http://example.com/
destination:
plugin: 'entity:file'
process:
fid: fid
filename: filename
source_full_path:
-
plugin: concat
delimiter: /
source:
- constants/source_base_path
- uri
-
plugin: urlencode
uri:
plugin: file_copy
source:
- '@source_full_path'
- uri
filemime: filemime
status: status
Inside my article node migration file, I had the following:
'field_article_image/target_id':
plugin: migration
migration: image_files
source: field_article_image
but I realized that this would not work. The target_id coming from the image_files migration were really File Entity ID's, not media entity ID's. In the ideal world, I'd like to find a way to create a third migration, which would create this middle step, and migrate file entities into Media Entities and then map that migration to the Articles migration. However, I can't figure out a good way of doing this.
Plan B will simply be to create a process plugin for the images migration, which will manually create file entities, attach them to media entities, and pass that migration over to Articles (this removes the middle step). This would mean, though, that while Media entities can be rolled back, File Entities could not.