Now the Migrate has landed in core we need a migration example too.

Issue fork examples-2182621

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

claudiu.cristea’s picture

Status: Active » Needs review
FileSize
27.54 KB

Here's a first attempt. Some notes:

  • Migrate in core is under heavy development. Most of the work taking place in a sandbox project at https://drupal.org/sandbox/chx/2105305. For this reason this module cannot be tested right now against core but needs to be tested on the code from sandbox.
  • API might still change until reaching a stable stage.
  • The 'body' field from the content is not migrated yet due to https://drupal.org/node/2164451. A new patch will be posted as soon as we can migrate fields.
marvil07’s picture

@claudiu.cristea: It is a great start, thanks for the work!

Added to the main list at #1880976: [meta] Port examples (including submodules) to D9.4+.

Definitely something to add to examples. I would prefer to wait a little until the related patches arrive to core.

In the other hand, the patch now includes examples for:

  • A user migration from database.
  • A user role migration from database.
  • A node migration from database.
  • A migrate process plugin.
  • Several migrate sources to use on the migrations.

It also includes some code to per-populate data into the database to be imported.

I remember migrate in D7 has some examples. Maybe it worths to also port some of the code there, i.e. to show that migration can import from i.e. xml or some other format.

I would suggest to ask this to the imp group, so we try to cover all of the migrate api with the least possible code :-)
I'll asking at the imp group post to follow the discussion here.

Thanks again to start this!

claudiu.cristea’s picture

I would prefer to wait a little until the related patches arrive to core.

Yes, agree. I only wanted to start.

I remember migrate in D7 has some examples. Maybe it worths to also port some of the code there, i.e. to show that migration can import from i.e. xml or some other format.

Sure. We have to look and port most important migrations and show cases here but this can be pushed in when sandbox work is in core. We can add new cases in the future.

claudiu.cristea’s picture

FileSize
27.53 KB
3.81 KB

Fixed also the 'body' field.

Mile23’s picture

+++ b/migrate_example/migrate_example.module
@@ -0,0 +1,48 @@
+ * Migrate examples provided by the module:
+ *
+ * - migrate_example_user_role: Migrates the source groups into Drupal roles. The source doesn't keep a separate table for groups, we are processing them from the people table.
+ * - migrate_example_people: Migrates the list of users into Drupal. This migration request a simple custom process plugin 'explode' that expands the list of user groups from a semicolon delimited string to an array.
+ * - migrate_example_content: Migrates the source articles into destination node entities of type 'page'. Note that the article author is migrated using the map of the previous users migration.

The idea is that eventually these examples will end up in core itself. So we have to use core docblock standards, and that means wrapping these lines. :-)

Also, classes like Base and Explode should declare that they're @ingroup migrate_example.

Lots of nice looking code. Just a few coding standards issues. But it's better to have it working and useable (and have IMP in core!) at this point.

claudiu.cristea’s picture

FileSize
27.67 KB
5.48 KB

@Mile23, thank you. Fixed.

Status: Needs review » Needs work

The last submitted patch, 6: migrate-example-2182621-6.patch, failed testing.

claudiu.cristea’s picture

Forgot to add '-do-not-test' suffix. The test failure is irrelevant till IMP is in core.

claudiu.cristea’s picture

And here's a writeup around this module http://webikon.com/cases/migrating-to-drupal-8

Mile23’s picture

Component: Other » Migrate Example
claudiu.cristea’s picture

FileSize
2.63 KB
2.63 KB
Mile23’s picture

I suppose this is the issue to watch: #2121299: Migrate in Core: Drupal 6 to Drupal 8

Correct?

hass’s picture

I'm highly interrested in real life examples and not only these minimal fake ones. See #2208967: Migration of setting that require changes? and try to write an example that migrate all update hooks from google_analytics 6xxx and 7xxx to 8xxxx. Make sure you can run every missing update hook independently if it has not run in past and make sure all of them run in correct order.

amitgoyal’s picture

FileSize
27.91 KB
128 bytes

Reroll of #6 and #11.

I am able to migrate user roles and users successfully. Content migration runs without any errors but content is NOT being migrated.

I am using attached manifest file for the migration. Please see below the drush command output,

$: drush migrate-manifest manifest_example.yml --legacy-db-url=mysql://drupaluser@127.0.0.1:33066/d8
Running migrate_example_user_role                                                         [ok]
Running migrate_example_people                                                             [ok]
Running migrate_example_content                                                            [ok]
$: 

Can anybody explain how can I debug this issue?

amitgoyal’s picture

Status: Needs work » Needs review
Issue tags: +#dcdelhi
FileSize
28.59 KB
3.68 KB

Finally content migration is also done as this was not working per #14.

Now the whole migration (user roles, users, content) is working as expected.

hass’s picture

Can we add an example how a contrib module can migrate a setting located inside user.data, please? e.g. user.data.example_foo

Status: Needs review » Needs work

The last submitted patch, 15: migrate-example-2182621-15.patch, failed testing.

Mile23’s picture

Title: Migrate example » Add Migrate example
Assigned: claudiu.cristea » Unassigned
socketwench’s picture

So, there's already a non-Drupal to Drupal 8 migration example in the migrate_plus module. There may be some merit in making a D7 or D6 to D8 example?

valthebald’s picture

Version: 8.x-1.x-dev » 3.x-dev
Parent issue: » #3150762: [META] New examples for 9.4+

Moving to new examples meta

ressa’s picture

I agree @socketwench. With the upcoming EOL of Drupal 7 later this year (November 2023) it would be awesome with an example migration from the standard Article content type, as well as a custom content type from Drupal 7 to Drupal 10, users, terms, etc.

It will come in handy.

jungle’s picture

Version: 3.x-dev » 4.0.x-dev

Baach made their first commit to this issue’s fork.