I need to migrate D7 variable user.data.googleanalytics.custom to D8 user.data.google_analytics.user_account_users variable.

Core seems to migrate user.data, but I cannot hook into this process to rename variables or at least I do not know how.

How can this implemented?

Comments

hass created an issue. See original summary.

hass’s picture

Issue summary: View changes
hass’s picture

Issue summary: View changes
mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

Haven't looked at this previously myself, but it looks to me like your model should be d6_user_contact_setting.yml - basically, replace

  constants:
    key: contact
    module: contact

with

  constants:
    key: user_account_users
    module: google_analytics
hass’s picture

The source is without underscore and destination with underscore in module name. What is index?

hass’s picture

Status: Postponed (maintainer needs more info) » Active

I tried to understand this now for several hours, but do not understand what happens.

  • key and module in destination does not work.
  • getDestinationProperty() takes all names from source!??? Looks like a core bug.
  • The value in D7 googleanalytics.custom is converted to D8 googleanalytics.custom with serialized value a:1:{s:6:"custom";i:1;} and not google_analytics.user_account_users with a non-serialized value 1.
id: d7_google_analytics_user_settings
label: Google Analytics user settings
migration_tags:
  - Drupal 7
source:
  plugin: d7_user
  constants:
    key: custom
    module: googleanalytics
process:
  uid: uid
  key: 'constants/key'
  module: 'constants/module'
  settings:
    plugin: skip_row_if_not_set
    index: googleanalytics
    source: data
destination:
  plugin: user_data
  key: user_account_users
  module: google_analytics
migration_dependencies:
  required:
    - d7_user
mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

What I suggested was changing the key and module in source, not adding a key and module to destination.

Try this:

id: d7_google_analytics_user_settings
label: Google Analytics user settings
migration_tags:
  - Drupal 7
source:
  plugin: d7_user
  constants:
    key: user_account_users
    module: google_analytics
process:
  uid: uid
  key: 'constants/key'
  module: 'constants/module'
  settings:
    plugin: skip_row_if_not_set
    # This is the part I'm not sure of, maybe it should be 'googleanalytics/custom'
    index: googleanalytics.custom
    source: data
destination:
  plugin: user_data
migration_dependencies:
  required:
    - d7_user
hass’s picture

I can try this, but it is not logic to me. The source has a wrong module name and wrong key that do not exists in the source.

If this really works i change this into a bug for sure as it makes no sense.

hass’s picture

Status: Postponed (maintainer needs more info) » Active

Both googleanalytics.custom and googleanalytics/custom result in no data migrated to D8.

Played a bit with SkipRowIfNotSet and this does not match. This means it is a syntax issue or the string is not split by PROPERTY_SEPARATOR and therefore the array key is not found.

  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    // This condition fails!
    if (!isset($value[$this->configuration['index']])) {
      throw new MigrateSkipRowException();
    }
    return $value[$this->configuration['index']];
  }
hass’s picture

Title: How to migrate user.data? » SkipRowIfNotSet plugin is not reusable
Category: Support request » Bug report

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

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

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

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

heddn’s picture

Status: Active » Postponed (maintainer needs more info)

There seems like would be a way to rename things using static_map, etc. If I'm not reading the IS correctly, please update it. Otherwise, I think things are working as designed.

hass’s picture

Status: Postponed (maintainer needs more info) » Active

Can you read all, please? And try it out. Nothing works.

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

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

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

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

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

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

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

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

quietone’s picture

Status: Active » Needs review

Took a look at the google_analytics migration

  module: 'constants/module'
  settings:
    # Based on skip_row_if_not_set
    plugin: google_analytics_skip_row_if_not_set
    key: custom
    module: googleanalytics
    source: data

and transform method:

    if (!isset($value[$this->configuration['module']][$this->configuration['key']])) {
      throw new MigrateSkipRowException();
    }
    return $value[$this->configuration['module']][$this->configuration['key']];
  }

The custom transform is getting a nested value from the array to test but SkipRowIfNotSet isn't designed to work with nested arrays. It just does a simple check on the value at the index, $value[$this->configuration['index'].

Fortunately, the Get plugin will get values from an array so we can do the following which allow skip_row_if_not_set to get the desired value to test.

settings:
  plugin: skip_row_if_not_set
  index: 'custom'
  source: data/google_analytics
quietone’s picture

Status: Needs review » Closed (works as designed)

No reply in over two weeks, closing as works as designed. Please reopen if that doesn't solve the problem.

hass’s picture

Status: Closed (works as designed) » Needs review

How can this work if source module was named googleanalytics and target module is named google_analytics. Somewhere I need to specify the source module I think...?

I try this:

settings:
    plugin: skip_row_if_not_set
    index: 'custom'
    source: data/googleanalytics
hass’s picture

Category: Bug report » Support request
Status: Needs review » Fixed

Seems working. THANKS!

Status: Fixed » Closed (fixed)

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