2

I have a situation where I am working on Drupal 6 to Drupal 7 migration. The migration is being done in stages, and stage one is now live.

I am working on stage 2, and have run into a snag file file migrations.

We had a content type 'foo' with field 'field_bar'. It was originally created as File, but should have been image. We ran migrations, and everything went OK (all files were part of original migration).

'foo.field_bar' got deleted and recreated as Image. When we re-run migrations, the files aren't being attached.

As far as I can tell, is that the source/destination pair exists in {migrate_map_files} but the fid doesn't exist in {file_managed}, more than likely because it got deleted during garbage collection when cron ran.

What is the best option to force these migrations to run again? Is there a way to do this with the Migration classes, or should I delete the bad rows from {migrate_map_files}?

  • how did you rerun the migrations? – Andre Baumeier Mar 31 '15 at 16:17
  • Reset the watermark in {migrate_status} and then drush mi files. It says it updated all of the files, but there are still orphaned sources w/ no corresponding entry in {file_managed}. – mpdonadio Mar 31 '15 at 16:18
1

My current solution is to use a query, and manually cleanup the {migrate_map_files} table

$fids = db_query('
  SELECT mmf.sourceid1 FROM {migrate_map_files} mmf
  LEFT JOIN {file_managed} f ON f.fid = mmf.destid1
  WHERE f.fid IS NULL
')->fetchCol();

db_delete('migrate_map_files')
  ->condition('sourceid1', $fids, 'IN')
  ->execute();

reset the watermark in {migrate_status} and then re-run my files migrations.

1

Usually you can set the needs_update column to 1 for all the known entities that have this issue, if you do this and run the migration with drush migrate-import MyMigration --needs-update. The other way would be to force update all items: drush migrate-import --update MyMigration

  • When I do this the migration runs, it says that the files have been updated, but the corresponding entry in {file_managed} still doesn't exist. – mpdonadio Mar 31 '15 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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