By nikhilsukul on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Introduced in version:
8.x-dev
Description:
In Drupal 7 or earlier, we used hook_update_N() for all upgrades including major version upgrades like Drupal 6 to Drupal 7. In Drupal 8, we still use hook_update_N() for minor upgrades that stay on Drupal 8 (ie. 8.x to 8.x upgrades). But for major version upgrades (like Drupal 7 to Drupal 8) you will need to write a migration with the Migration API. Without reading this introduction page (just the page, not the children, is enough) this change notice will be very hard to understand.
Variable - to - config upgrade, D7-style
function system_update_8009() {
update_variables_to_config('system.cron', array(
'cron_safe_threshold' => 'threshold.autorun',
'cron_threshold_warning' => 'threshold.requirements_warning',
'cron_threshold_error' => 'threshold.requirements_error',
));
}
Variable - to config migration
You need to create a migration configuration entity which specifies the following:
- The source is provided by the Drupal variable plugin. This plugin, somewhat unusually, requires much configuration, namely the list of variables to be read. Most source plugins provided by the Migrate Drupal just provide one source row per SQL table row without much configuration.
- How each configuration key is created from the source. To understand this particular example better, reading the process introduction at https://drupal.org/node/2129651 is recommended.
- The results should be saved into a configuration file. The
configdestination plugin requires little configuration: just the name of the configuration file. Other common destinations are entities, likeentity:node.
Putting this all together we get migrate.migration.d6_system_cron.yml:
id: d6_system_cron
source:
plugin: variable
variables:
- cron_threshold_warning
- cron_threshold_error
- cron_last
process:
'threshold:warning': cron_threshold_warning
'threshold:error': cron_threshold_error
destination:
plugin: config
config_name: system.cron
Impacts:
Module developers