I am migrating roles from D6 to D8 with Migrate. D6 roles are mapped to existing D8 ones, which should not be removed (see my migration below). At rollback, the Pro+ role is removed. Apparently, Migrate uses a rollback_action which has two possible values, as defined in MigrateIdMapInterface:

  /**
   * Codes reflecting how to handle the destination item on rollback.
   */
  const ROLLBACK_DELETE = 0;
  const ROLLBACK_PRESERVE = 1;

I tried to use this key in my YAML file at different levels, to no avail. Could you help me?

id: myproject_d6_user_role
label: 'User roles'
migration_group: myproject_d6
source:
  plugin: d6_user_role
process:
  id:
    -
      plugin: static_map
      source: name
      bypass: false
      map:
        'Utilisateurs anonymes': 'anonymous'
        'Utilisateurs enregistrés': 'authenticated'
        'Gestionnaire des utilisateurs': 'redacteur'
        'Pro+': 'pro_plus'
        'Utilisateurs professionnels': 'pro_plus'
    -
      plugin: user_update_8002
  permissions:
    -
      plugin: static_map
      source: permissions
      bypass: true
      map:
        'post comments without approval': 'skip comment approval'
    -
      plugin: system_update_7000
    -
      plugin: node_update_7008
    -
      plugin: flatten
    -
      plugin: filter_format_permission
destination:
  plugin: 'entity:user_role'
  rollback_action: 1
rollback_action: 1
migration_dependencies: {  }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

FMB created an issue. See original summary.

heddn’s picture

Issue tags: +Needs documentation

Version: 8.3.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

@heddn, where do you suggest this is documented, DestinationBase?

heddn’s picture

That makes sense to mention it in DestinationBase. But since its a constant on MigrateIdMapInterface, we should probably discuss it more there. I sense it is more of an id map thing.

quietone’s picture

Version: 8.9.x-dev » 9.1.x-dev
Category: Support request » Task
Status: Active » Needs review
FileSize
1.56 KB

Changing to a task.

How about this, which adds a description of each migrate_map property?

heddn’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/migrate/src/Plugin/MigrateIdMapInterface.php
    @@ -13,6 +13,23 @@
    + * - sourceidN: Any number of source IDs defined by a source plugin.
    + * - destidN: Any number of destination IDs defined by a destination plugin.
    

    I get what we are wanting to communicate here. Where there are N number of source and destination columns. But for the non initiated, I think we could make this even more clear.

  2. +++ b/core/modules/migrate/src/Plugin/MigrateIdMapInterface.php
    @@ -13,6 +13,23 @@
    + *   - MigrateIdMapInterface::ROLLBACK_DELETE
    + *   - MigrateIdMapInterface::ROLLBACK_PRESERVE
    

    We don't really elaborate on these 2 values. Shouldn't we?

quietone’s picture

Status: Needs work » Needs review
FileSize
2.24 KB

@heddn, thanks.

Changes as suggested. No interdiff because this is so small.

heddn’s picture

Status: Needs review » Needs work
+++ b/core/modules/migrate/src/Plugin/MigrateIdMapInterface.php
@@ -13,6 +13,25 @@
+ *   - MigrateIdMapInterface::STATUS_IMPORTED: The row was imported.
+ *   - MigrateIdMapInterface::STATUS_NEEDS_UPDATE: The row needs to be updated.
+ *   - MigrateIdMapInterface::STATUS_IGNORED: The row was ignored.
+ *   - MigrateIdMapInterface::STATUS_FAILED: The row failed to import.
...
+ *   - MigrateIdMapInterface::ROLLBACK_DELETE
+ *   - MigrateIdMapInterface::ROLLBACK_PRESERVE

The status constants we define in-line. The rollback ones we don't. I feel we should keep that in sync and add a couple lines on the rollback ones to help clarify. Alternatively, remove all the status in-line and update their constant docs.

quietone’s picture

Title: How to use rollback_action in a migration » Document MigrateIdMapInterface.
Status: Needs work » Needs review
FileSize
2.38 KB

I wasn't happy with that section myself. I really don't think the constants should be explained like that in the interface doc block. How about adding documentation for the status constants and simply refer to them in the doc block. And lets expand the scope to 'add documentation' to MigrateIdMapInterface.

What do you think?

edit: s/was/wasn't/

heddn’s picture

Status: Needs review » Reviewed & tested by the community

Much better. Nice good docs!

alexpott’s picture

Version: 9.1.x-dev » 8.9.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed ff18b59a49 to 9.1.x and 63bb3cbb0b to 9.0.x and 9d7cfefe1e to 8.9.x. Thanks!

Backported to 8.9.x as this is a docs fix.

  • alexpott committed ff18b59 on 9.1.x
    Issue #2912244 by quietone, heddn, FMB: Document MigrateIdMapInterface
    

  • alexpott committed 63bb3cb on 9.0.x
    Issue #2912244 by quietone, heddn, FMB: Document MigrateIdMapInterface...

  • alexpott committed 9d7cfef on 8.9.x
    Issue #2912244 by quietone, heddn, FMB: Document MigrateIdMapInterface...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.