Preventing deletion of files on rollback

Last updated on
30 April 2025

If you are populating file fields on migration, and don't want the files to be deleted on rollback (e.g., you copied the files manually into the Drupal files directory and are using file_link to point to the pre-existing file), use the 'preserve_files' argument in your mapping:

    $this->addFieldMapping('field_commerce_file_s3', 'commerce_file_s3')
      ->arguments(array('preserve_files' => TRUE));

Similarly, to keep files imported by a migration into MigrateDestinationFile, pass the 'preserve_files' option to the constructor:

    $this->destination = new MigrateDestinationFile(array('preserve_files' => TRUE));

Help improve this page

Page status: Not set

You can: