Migrate Rollback puts entities into trash

Created on 12 February 2025, 28 days ago

Problem/Motivation

I am seeing some regression in how Migration works after enabling this module. In the past drush migrate:rollback would ensure the environment state is clean. After enabling Trash module the entities affected by rollback are kept in the purge queue.

I am not sure if that's by design but in my head, this is a bug as it changes one of the most fundamental parts of the Migrate API - the ability to clean up the environment after the migration.

Steps to reproduce

Use any example migration for testing. Upon rollback observe the migrated entities weren't removed.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇳🇴Norway zaporylie

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @zaporylie
  • 🇷🇴Romania amateescu

    I agree that rolling back a migration should delete the entities instead of trashing them. If Migrate has an API for hooking into the rollback process (before it starts), we need to set the ignore trash context like we do for similar use-cases, e.g. \Drupal\trash\EventSubscriber\TrashIgnoreSubscriber::onDefaultContentPreImport().

  • 🇳🇴Norway zaporylie

    Thanks for the feedback Andrei, I'll have a closer look tomorrow. Meanwhile, I thought about one more case - if the item is removed from the migration source and migration import is being run with --sync flag that should also purge the item directly. Thoughts?

    ref:

     --sync                                Sync source and destination. Delete destination records that do not exist in the source.                            
    
  • 🇷🇴Romania amateescu

    That one sounds like it should be configurable.. I don't think either trashing or deleting the entities on the destination is the correct answer in all situations.

    Can we add custom flags to the migration process/command? Like --trash=true|false?

Production build 0.71.5 2024