Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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));
Comments
Using file_usage_add()
I'm attempting to deal with this in a custom MigrateCommerceFileFieldHandler::buildFileArray() using:
What about when using the MigrateFileFieldHandler as an argument
I am using MigrateFileFieldHandler to generate my arguments. How do I work this parameter in with that? Do I chain another argument call onto this?
Example:
Patrick Thurmond
patrickthurmond.com