Migrations: Mapping tables not updated when entities are deleted

Created on 19 September 2024, 4 months ago

Problem/Motivation

When a migrated entity is manually deleted, the ID is not removed from the migration mapping table.

This stop that item from be re-imported and can result in unexpected behaviour.

Steps to reproduce

1. Create a simple migration and run the import
2. Manually delete one of the entities created by the migration
3. Check the mapping table for the migration: the destination entity ID, of the deleted entity, is still there

Proposed resolution

Update the migration mapping table and always remove IDs of removed entities

OR

Add an option on the migration to automatically remove from mappings IDs of removed entities.

Remaining tasks

1. Agree on solution
2. Implementation

User interface changes

N/A

Introduced terminology

N/A

API changes

Potential change in migration YML file structure (adding a new option)

Data model changes

N/A

Release notes snippet

Deleting an entity imported by a migration now removes its ID from the migration mapping table

OR

It's now possible to configure a migration to automatically remove a deleted entity's ID from the mapping table.

πŸ› Bug report
Status

Active

Version

10.2 ✨

Component
MigrationΒ  β†’

Last updated about 11 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom khaled.zaidan

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

Comments & Activities

  • Issue created by @khaled.zaidan
  • πŸ‡¬πŸ‡§United Kingdom khaled.zaidan
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    This is working as designed. The migration map tables track the state of a row after the migration process is complete, they are completely independent of any other database table.

    This can be resolved using drush, To re-run the migration and re-import a row that was deleted in the destination use the --update flag.

  • πŸ‡ΊπŸ‡ΈUnited States mikelutz Michigan, USA

    This is neither reasonably possible, nor desired. The map table is a record of what we did, not something that reflects the current state of the system. More importantly the meaning of destination ids is completely plugin defined. They have no relationship to entities at all, so there would be no way to connect a deleted entity to a map table entry. The issue summary describes a custom workflow and problem that is best solved in custom code, where the custom code is aware of the specific relationships between migration destination maps and entities in use in that particular site.

Production build 0.71.5 2024