d8 migration plugins - drupalcon...d8 migrate in core background the migrate and drupal-to-drupal...

33

Upload: others

Post on 16-Jul-2020

10 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope
Page 2: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

D8 Migration PluginsMIKE ANELLO, RYAN WEAL, KEITH DECHANTW r i t i n g a C u s t o m M i g r a t i o n P l u g i n f o r D 8

Page 3: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

Who are we?Mike Anello (ultimike)Keith Dechant (kdechant)Ryan Weal (Ryan Weal)

Page 4: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

Who are you?Contrib module developers

Custom module developers

Migrate-curious

Oops, I'm in the wrong room!

Page 5: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

D8 Migrate in Core BackgroundThe Migrate and Drupal-to-Drupal Data Migrationmodules have been rewritten and moved intoDrupal 8 core.Their scope has been expanded to supportmigration of content and configuration.

Page 6: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

D8 Migrate in Core Backgroundcore/modules/migratecore/modules/migrate_drupal

Page 7: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

D8 Migrate in Core StatusMost of the D6->D8 migration work is done - somebugs remain.The D7->D8 migration work is just getting started.The migration UI is not {yet} in core.Rollbacks and other advanced features not yet incore.

Page 8: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

D8 Migrate in Core StatusSprint with us tomorrow and Saturday.#drupal-migrategroups.drupal.org/imp

Page 9: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

Extensible! (Duh)The best part: D8 migration API is extensible.Leverages standard D8 plugins.Contrib/custom module authors will be able toprovide migration support for the content andconfiguration data their module manages.

Page 10: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

Kinds of MigrationsVariable Migrations (relatively easy)

Field migrations

Entity-type migrations (more complex)

Others (?)

Page 11: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

Kinds of MigrationsVariable Migrations (relatively easy)

Field migrations

Entity-type migrations (more complex)

Others (?)

Page 12: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

Field Module MigrationsWhen we want to migrate a field (configurationand content), we actually need to run severalmigrations...

Page 13: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope
Page 14: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

Field Module MigrationsLuckily, most of the time we only have to worryabout four of them...

Page 15: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope
Page 16: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

What does a migration configurationlook like?

D6_FIELD.YMLsource (get the data)process (map fields and massage the data)destination (save the data)

Page 17: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

What does a migration configuration

look like?

D6_FIELD.YML ­ SOURCE

Page 18: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

What does a migration configuration

look like?

D6_FIELD.YML ­ PROCESS

(MAP AND MASSAGE) status: active field_name: field_name type: - plugin: static_map source: - type - widget_type map:

Page 19: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

What does a migration configuration

look like?

D6_FIELD.YML ­

DESTINATIONdestination: plugin: entity:field_storage_config

Page 20: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

Each of these migrations works the same way!

Page 21: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

TaskCreate a migration plugin for the D6 Iframemodule.https://drupal.org/project/iframe

Page 22: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

TaskWe're not going to demo porting the entiremodule.We're going to migrate D6 iframe fieldconfiguration and data to D8 Link fieldconfiguration and data.

Page 23: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope
Page 24: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

TaskAll we have to do is add new configuration toexisting migrations.Why not modify configuration files directly?Why not write a separate migration for it?

Page 25: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope
Page 26: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

Inform d6_field.yml about the iframe field type, d6_field_instance_widget_settings.yml about the iframewidget mapping, etc...

Page 27: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

Plugins!A recent core commit(https://www.drupal.org/node/2448501) makes itpossible to define a new field migrations with aplugin.The abstract CckFieldPluginBase class providesthe basic functionality that we can expand on.CckFieldPluginBase implementsMigrateCckFieldInterface.

Page 28: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

MigrateCckFieldInterface*processField - add field type mappings*processFieldInstance - add field instancemappings*processFieldWidget - add field widget mappings*processFieldFormatter - add field formattermappings

Page 29: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

MigrateCckFieldInterface (continued)getFieldFormatterMap - defines the formattermap*getFieldWidgetMap - defines the widget mapprocessCckFieldValues - defines new processplugin

* implemented by abstract CckFieldPluginBase class

Page 30: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

The PlanSubclass CckFieldPluginBaseWrite a custom process plugin to massage iframefield data into Link field data.

Page 31: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

Code Walkthrough

https://www.drupal.org/sandbox/benjy/2422307

Page 32: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

Future TasksPort the rest of the module?Create an iframe field formatter for Link field?

Page 33: D8 Migration Plugins - DrupalCon...D8 Migrate in Core Background The Migrate and Drupal-to-Drupal Data Migration modules have been rewritten and moved into Drupal 8 core. Their scope

What did you think?EVALUATE THIS SESSION ­

EVENTS.DRUPAL.ORG/NODE/1011

THANK YOU!