Custom Drupal-to-Drupal Migrations with Migrate Tools

Image
On the Drupal Migration Trail

Editor's note: To learn how to upgrade/migrate to Drupal 8, follow our full Drupal 8 Migration Guide.

Drupal 8 core provides support for Drupal-to-Drupal migrations. Since there is no direct upgrade path for Drupal 6 or 7 to 8, you should become familiar with the migration system in Drupal, as it will allow you to migrate your content from previous versions to Drupal 8.

In this post, which is aimed at advanced Drupal users, we will discuss how you can conduct a custom Drupal-to-Drupal to migration using core, and contributed modules, along with Drush.

If you have not yet read Mike Ryan's excellent blog post about the changes to the Migrate System in Drupal 8.1, I would highly recommend it.

Preparation

To be able to run custom Drupal-to-Drupal migrations in Drupal 8, you will need the following:

  • Drupal 8.1 (or greater) installed
  • A database backup from your Drupal 6 or 7 site, and optionally, your sites/default/files directory from your Drupal 6 or 7 site
  • A database backup of your freshly installed Drupal 8.1

Enable the following modules in your Drupal 8.1 site:

Core:

  • Migrate
  • Migrate Drupal

Contributed:

After enabling the required modules, add an additional database definition to your settings.php for your Drupal 8.1 site. See Drupal\migrate\Plugin\migrate\source\SqlBase

// Database entry for `drush migrate-upgrade --configure-only`
$databases['upgrade']['default'] = array (
  'database' => 'dbname',
  'username' => 'dbuser',
  'password' => 'dbpass',
  'prefix' => '',
  'host' => 'localhost',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);
// Database entry for `drush migrate-import --all`
$databases['migrate']['default'] = array (
  'database' => 'dbname',
  'username' => 'dbuser',
  'password' => 'dbpass',
  'prefix' => '',
  'host' => 'localhost',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);

Generate a migration

With these steps complete, it's time to generate a migration. Open up a terminal, and issue the following command, from your Drupal 8.1 root directory:

drush migrate-upgrade --configure-only

If you didn’t create an entry in your settings.php you can pass your database credentials for your Drupal 6 or 7 site, and optionally, the path to the files directory like so:

drush migrate-upgrade --configure-only --legacy-db-url=mysql://dbuser:dbpass@localhost/dbname --legacy-root=/path/to/sites/default/files

This command will generate migration configuration entities in the active configuration store, using migration plugins in Drupal core. Check out the tutorial, Configuration Data Storage, to learn more about the configuration system in Drupal 8.

Create a custom migration module

At this stage, we need to create a custom module for our migration, in your Drupal 8.1 site. You can do this manually, or using Drupal Console, like so:



drupal generate:module

// Welcome to the Drupal module generator
 
Enter the new module name:
> custom_migration
    
Enter the module machine name [custom_migration]:
>
    
Enter the module Path [/modules/custom]:
>
    
Enter module description [My Awesome Module]:
> A custom Drupal-to-Drupal migration
    
Enter package name [Custom]:
>
    
Enter Drupal Core version [8.x]:
>
    
Do you want to generate a .module file (yes/no) [no]:
> no
    
Define module as feature (yes/no) [no]:
> no
    
Do you want to add a composer.json file to your module (yes/no) [yes]:
> yes

Would you like to add module dependencies (yes/no) [no]:
 > yes

 Module dependencies separated by commas (i.e. context, panels):
 > migrate_drupal, migrate_plus
    
Do you confirm generation? (yes/no) [yes]:
> yes
    
Generated or updated files
Site path: /Users/willwh/Sites/drupal
1 - modules/custom/custom_migration/custom_migration.info.yml
2 - modules/custom/custom_migration/composer.json

Export site configuration

Create the directory custom_migration/config/install , which is where we will store our custom migration.

We can now export our site configuration, which will include our generated migration configuration entities. If you’re not familiar with the configuration system Drupal 8, you should check out our Configuration Management tutorials, specifically Manage Configuration with Command Line Tools.


drush config-export --destination=/tmp/migrate

Copy migration configuration to custom module

Next, we need to copy the migration configuration generated by drush migrate-upgrade --configure-only to our custom_migrate/config/install.

These files will be at /tmp/migrate and begin with migrate_plus.

Caution

Warning! Make sure you do not copy the default configuration group that is defined by migrate plus, i.e. migrate_plus.migration_group.default.yml.

Use the following command, and replace the last argument with the correct path to your custom module’s config/install location:

cp /tmp/migrate/migrate_plus.migration.* /tmp/migrate/migrate_plus.migration_group.migrate_*.yml /path/to/your/module/config/install/

Edit your module’s migrations

At this point, you can simply remove any of the migrations you don’t need, along with any dependencies on them. You can also now edit the migrations contained in your module to your liking.

For example, if you don’t want to migrate blocks from your previous site, you would delete the following files at custom_migration/config/install :

  • migrate_plus.migration.upgrade_block_content_body_field.yml
  • migrate_plus.migration.upgrade_block_content_type.yml
  • migrate_plus.migration.upgrade_d7_block.yml
  • migrate_plus.migration.upgrade_d7_custom_block.yml

Customize migrations with process plugins

Migrations may also be customized with process plugins.

Let’s say you’re migrating from a Drupal 7 site. If you wanted to map a node type from a previous Drupal version to a different node type in Drupal 8, you could accomplish this with the default_value process plugin.

For example, given this migration template:

  • migrate_plus.migration.upgrade_d7_node_blog_post.yml

In the process: section of the migration, take note of the following:

process:
  type: type
  name: name
  description: description
...

Instead of mapping the node type in Drupal 7 to one of the same name in Drupal 8, which, in my example would import the blog_post content from Drupal 7, to a content type of blog_post in Drupal 8, we can use the default_value plugin, and specify a node type of a different name.

In the process: key, change the values for plugin to default_value and value to the machine name of your desired node type.

process:
  type:
    plugin: default_value
    value: desired_node_type
  name: name
  description: description
  help: help
  title_label: title_label
  preview_mode: constants/preview
  display_submitted: display_submitted
  new_revision: options/revision
  create_body: create_body
  create_body_label: body_label

Run the customized migration

To run your migration, you must import your clean backup of Drupal 8.1, enable the required modules above, and your new custom_migration module.

You can check that you have everything set up correctly by running drush migrate-status. You should see a list of all of the migrations you have defined in your module.

A portion of my custom migration status looks like this:



Group: default                                  Status  Total  Imported  Unprocessed  Last imported
 upgrade_block_content_type                      Idle    1      0         1
 upgrade_d7_dblog_settings                       Idle    0      0         0
 upgrade_d7_image_settings                       Idle    0      0         0
 upgrade_d7_node_settings                        Idle    1      0         1
 upgrade_d7_search_settings                      Idle    1      0         1
 upgrade_d7_url_alias                            Idle    4953   0         4953
 upgrade_d7_user_flood                           Idle    0      0         0
 upgrade_d7_user_mail                            Idle    1      0         1
 upgrade_menu_settings                           Idle    0      0         0
 upgrade_search_page                             Idle    1      0         1
 upgrade_taxonomy_settings                       Idle    0      0         0
 upgrade_text_settings                           Idle    0      0         0

To execute your migration, run the following:

drush migrate-import --all

Stay tuned…

We will cover this process in much greater detail in our upcoming Migrate to Drupal 8 tutorials, but I hope this will help you get started in migrating to Drupal 8!

Update (May 6, 2016): Our Drupal 8 Migration Guide is underway. Check out the latest tutorials on Drupal-to-Drupal migrations here.

Comments

Hi William,

thank you for your detailed tutorial, but there is a confusing mix-up in "Copy migration configuration to custom module" first you talking about

custom_migrate/install/config

and after that it is

custom_migrate/config/install

Can you tell me, what is right?

Best wishes

It seems that custom_migrate/config/install is right.

But now I got a bunch of errors after the "migrate-status" command

Argument 1 passed to Drupal\migrate\Plugin\migrate\source\SqlBase::setUpDatabase() must be of the type array, null given, called [error]
in /.../web/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php on line 87 and defined
SqlBase.php:114
The specified database connection is not defined: migrate

and after that I got the drush ms table, but without numbers

Group: migrate_drupal_6 Status Total Imported Unprocessed Last imported
upgrade_contact_category Idle n. v. 0 n. v.
upgrade_d6_date_formats Idle n. v. 0 n. v.

Hi Matthias, my apologies for the confusion here, I've updated the article, it should be at config/install.

The error you're running in to with migrate-status, sounds like you may be missing database credentials, for your D6 or D7 site in your settings.php of your Drupal 8 site.

Hi Matthias,

You could also pass the db credentials with drush migrate-upgrade --configure-only --legacy-db-url=mysql://dbuser:dbpass@localhost/dbname --legacy-root=/path/to/sites/default/files

Si successfully ran my Drupal 7 to 8 migration using your guide, Thanks! But I can't get field collections to migrate. It looks to me like the destination field is not created. here's the first error that comes out:

Missing bundle entity, entity type field_collection, entity id field_dsi_press_release_partner (/var/www/core/lib/Drupal/Core/Entity/EntityType.php:866)

and then this:
Attempt to create a field field_dsi_press_release_partner that does not exist on entity type node. (/var/www/core/modules/field/src/Entity/FieldConfig.php:286)

Any clue on how I can migrate those field_collections ?

I don't know what I'm doing wrong.
But I followed your steps, have the creds in the settings.php or with legacy-db.., legacy-root.
And I tested it with a "drush ms" after "drush migrate-upgrade --configure-only" and it works.
I copy the wanted yml-files in the config/install folder, import my clean D8.1 installation enable all required modules, run "drush ms" and got the error message from above.
Maybe it is somehow related that I'm using a D6 version?

Ok I solved the problem.
After reimporting the clean D8.1 database, I found out that the "\Drupal::state()->get('migrate_drupal_6');" is NULL and it seems to be consistent because we got a fresh database with no "drush migrate-upgrade --configure-only" to write the creds in Drupal::state.
So I used "drush php" and then \Drupal::state()->set('migrate_drupal_6', array('key' => 'upgrade' ...." to set the creds, and then "drush ms" and "drush mi --all" ran with my costume migration.

An other thing that happened during the migration process is that files weren't migrated when I write the creds in the settings.php alone. I have to use the --legacy-root option that files were migrated correctly.
You should mention that files migration only works with this option.

Thanks for the heads up. We'll look into this and make sure that the post gets updated. A quick look at the code in \Drupal\migrate_upgrade\MigrateUpgradeDrushRunner::configure makes it look like that changes to settings.php might not be necessary at all if you're using Drush to run the migration since Drush doesn't ever read those settings in and instead alway requires the options passed in when calling the commands.

Hi

I am running into what I believe is a similar problem.
After having followed the instructions (i.e. after installing the fresh D8.1 database and enabling the required modules), I try to run drush migrate-status and get a load of messages like:

Driver not specified for this database connection: drupal_6
.
.
... and ...
.
.
upgrade_d6_file_settings Idle N/A 0 N/A
.
.

So, it seems the database data from settings.php isn't "available"
Following Matthias I tried something like: drush php ... and
\Drupal::state()->set('drupal_6', array('key' => 'upgrade', array('database'=>'My_d6_backup','username' => '', 'password' => '', 'prefix' => 'dr_', 'host' => 'localhost', 'port' => '3306') ) )

However, this doesn't do the trick ... now, the reason is probably because there is an error in my state()->set statement but I just don't see where. If you could give an detailed explanation on what to do in the "Run the customized migration" paragraph of your tutorial, I would really appreciate it

I have few issues with migration from Drupal 6:
1. only titles are imported for nodes (node authors are migrated correctly)
2. no fields for nodes are created
3. profile fields are created, but for text fields it also contains format (like on screenshot: http://imgur.com/NALI8k0)
4. profile fields content is not migrated

Wich imports should I edit to handle those fields for profile? upgrade_user_profile_field, upgrade_user_profile_field_instance, upgrade_d6_profile_values?

Same for nodes - do I need to add somethign in upgrade_d6_field file? or rather upgrade_d6_field_instance?

Hi Omkara,

From the error: Driver not specified for this database connection: drupal_6, I wonder, did you copy or create amigrate_plus.migration_group..yml in to your /config/install directorythat defines a 'drupal_6' source key?

Do you have a $databases['migrate']['default'] defined in your settings.php?

Looking at core/modules/views/src/Plugin/views/pager/SqlBase.php:

"By default, an existing database connection with key 'migrate' and target 'default' is used. These may be overridden with explicit 'key' and/or 'target' configuration keys. In addition, if the configuration key 'database' is present, it is used as a database connection information array to define the connection."

Let me know if that helps!

Thanx Willwh

There was indeed a migrate_plus.migration_group.migrate_drupal_6.yml file that had drupal_6 source key. I tried filling in the relevant data in the file but it didn't help. But when this file was removed from the custom_migration/config/install folder and after having dropped the database and imported the "fresh" database, I got a sensible result from running 'drush ms'

Another thing, that may be supremely unimportant, is that when I first tried running 'drush migrate-upgrade --configure-only' it gave a 'Driver not specified for this database connection: upgrade' so I had to change $databases['migrate']['default'] to $databases['upgrade']['default'] in the settings.php file and then the misc yml-files were generated.
However, aftterwards, when running 'drush ms' the system gave a 'The specified database connection is not defined: migrate' and I had to change it back to $databases['migrate']['default'] in the seetings.php file

In any case, a 1000 thanks for the input

@ Omkara:

mh your state()->set statement seems to be correct, the only thing that comes to my mind is that you have to be careful with the database_state_key.
Look into the migrate_plus.migration_group.....yml file and copy the database_state_key: migrate_drupal_6 in your set() statement like:
\Drupal::state()->set('migrate_drupal_6', ...

@ Vichy:

I got the same problems, with migrate-import fields will not be imported correctly.

Will,

At first I looked at the title of this article, and said, no, I don't want anything "Custom," I just want to migrate a basic D6 site to D8. However, I now understand that _everything_ is Custom.

I am having an issue that seems to have stopped me almost before I started.

I have created a brand-new Drupal 8.1.6 site for this migration, using Drush 8.1.2. I had enabled all three Migrate modules in the Drupal Admin UI, and then added migrate_tools and migrate_plus from Drush.

However, when I issue the "drush migrate-upgrade --configure-only" command, I get told that there is no such command as "migrate-upgrade."

I have confirmed in the Admin UI that "Migrate," "Migrate Drupal," and "Migrate Drupal UI" are all enabled. I have confirmed through Drush that migrate_tools and migrate_plus are enabled.

Am I missing some module, or have I done something else wrong?

Thanks,
Brian

I found that even though all three D 8.1.6 Core Migrate modules were installed and enabled, and even though I had installed migrate_tools and migrate_plus through Drush, I still needed to install migrate_upgrade through Drush before these instructions would work.

I also needed to install Drupal Console, as suggested.

Hi there William,

Thanks for this article... I followed your steps using a fresh installed d7 and d8 on our server... I encountered some errors in the last part of the steps. It's more on like sql/database error messages.

I just would like to confirm in Preparation step, under database "add an additional database definition to your settings.php".

Is the first database entry, a d8 database? and the second is the d7 database creds?

Would appreciate if you could response to my question asap.!

-John Rey

In response to John Rey:

Hey John,

Both of the database entries in the example are for the site you are migrating from, Drupal 6 or 7. In fact, they will have all of the same values except for the array index.

$databases['upgrade']['default'] will be used by the command: drush migrate-upgrade

$databases['migrate']['default'] is used by: drush migrate-import

Thank you so much for that quick response Jon... Will try it now migrating a live site to a fresh drupal 8.. Hopefully it will works on me...

I got past my previous errors and have been stopped again. I am probably not reading correctly.

I started out by creating a new D8 site as the "target" site. I then, after a few steps in Will's instructions, successfully performed the migrate-upgrade, and the config-export.

However, between those, I was instructed to use the Drupal Console to create and install a second new D8 installation.

I was also told to create a directory custom_migrate. Is that directory inside one of the D8 installations, or outside, somewhere?

As well, when I looked in /tmp/migrate, I didn't see any migrate_plus.migration_group.default.yml. Since I was told not to copy it, I didn't really worry about that, but was a bit concerned that the migrate-upgrade or the config-export may not have worked correctly.

Right now, I am stuck at the copy command, because I am not sure where my " /path/to/your/module/config/install/" should go. Is this the custom_migrate directory, and if so, my earlier question about where that should go applies? If not, where is this directory?

Thanks,
Brian

"I was also told to create a directory custom_migrate. Is that directory inside one of the D8 installations, or outside, somewhere?"

The directory that you need to create is config/install and it lives inside of the custom module that you've created to hold your migration code. In Will's case he created a module name "custom_migration" so the directory, including the root directory of the module would be custom_migration/config/install. If your module has another name that path might be different.

And yeah, once you've got that 'config/install' directory within your custom module that is where you'll need to copy the .yml migrate files generated by the config-export command.

I'm sorry, Joe, but I am still in the dark.

OK, so "custom_migrate" is Will's custom module, but is it inside the D8 that I created as the target of my migration, inside the D8 created by the Drupal Console procedure that Will said to do, or is it in an outside directory somewhere?

I had originally created "custom_migrate/config/install" in the same parent directory where the Drupal Console D8 was placed ( BESIDE the D8 ), and copied all of the "migrate*" files from /tmp/migrate into it.

Because of the order of events in this article, I started the migrate process in my "target" D8, and then used Drupal Console to create a second one.

I'm afraid that I am still confused about the directory structure that I need to have.

This is my first attempt at a D6->D8 migration, and I am using this as a learning process so that I can continue and migrate the other 10 or 12 sites that need it.

Thanks,
Brian

Thanks for the tutorial on doing a custom migration. This works and I'm so happy to see a lively and ongoing current discussion about migrations. I did a D6 - D8 custom migration and thanks to the comment thread as well as some discovery I have made prior to this helped me through the rough patches. It works!

For those struggling with the error message: `Driver not specified for this database connection: drupal_6`, do the following:

1) Remove: migrate_plus.migration_group.migrate_drupal_6.yml from the `/config/install` directory in your custom module.

2) Uninstall the migration modules that you are using, specifically "Migrate Plus".

Doing so will remove the migration configuration and all of the migrations that your custom migration module registered to your Drupal 8 site when you installed your custom module. It is like starting back with a clean slate.

File Migration Troubles
One area I am still struggling with is migrating file fields. I think it's because my custom module doesn't know where to look for the file system path. Initially I thought that if I copied the files from the old site `/sites/default/files`, it would be fine but I still receive the error that the file was not found.

Any ideas about how to tell the custom_migration module where it should be looking for files?

Date Field Problems
I also ran into the problem of dates not being migrated but I am certain this can be fixes in a YML configuration file somewhere in my custom_migration module.

This is great stuff! Thanks again for posting it.

Andrew

Joe,

I thought that I had answered my last note, but I don't see it.

Going back through the instructions, I found that "custom_migrate" was created as part of the Drupal Console process. I had thought that the instructions after that were telling me to create the whole path, rather than just the sub-directories of that directory that already existed.

I went past that, and then ran into issues with my "drush ms". I will go through the comments above, and see if I can solve at least some of these before I come back.

I am also wondering whether I should be using the Drupal Console installation as my "target" one, instead of the one that I had at the beginning of this process. Suggestions?

I will also be using Andrew's latest comments to help me with this.

Hi Joe,
I'm not sure where you got hung up in the process after the Drupal Console part but I am guessing that it was when you copied the configuration from the tmp files to your custom module. Here's what I did:

1) Added the directories to my module: config/install

2) Copied the config YML files from tmp to the config/install directory using the "relative" path based on my shell being open in the root of my Drupal 8 and my custom module being located in modules/custom:

cp /tmp/migrate/migrate_plus.migration.* /tmp/migrate/migrate_plus.migration_group.migrate_*.yml modules/custom/custom_migration/config/install/

After that, you could uninstall the migration modules, back to "Migrate Plus" and then reinstall them + your custom migration module and if all is well, you'll be able to run a migration.

* Unfortunately I'll be away this weekend but I'll try to check back if I can.

Andrew

Has anyone had success migrating date and files fields in a custom migration?

I have had success with dates in a CSV custom migration (which is quite a different process than this) but I haven't had any success with date fields at all with either technique.

Thanks,
Andrew

Edit: ^ ^ ^

That should have read: ...but I haven't had any success with file fields at all with either technique.

I haven't had a chance to experiment with migrating files yet so I'm not likely to be of much help. Though this is hopefully something I'll be tackling in the near future.

First thing to check, are you passing the --legacy-root=/path/to/sites/default/files path to drush when running your migration?

Have you searched the core issue queue to see if anyone else is experiencing similar problems?

You could try joining #drupal-migrate on IRC and see if anyone there can offer some additional advice on what might be going wrong.

Thanks Joe,
I was not passing the reference to my legacy root files directory and wondered about where I would be passing that argument.

I incorrectly assumed that since the error I was getting was complaining about the files not being a '/sites/default/files/etc...' that I could manually move them there and Drupal would do the rest.

Thanks for the suggestions. I'll give them a go and report back.

Andrew

Hi Joe,
Me again...

How does one pass the argument for the legacy root to the migration drush processor? I have tried the following but --legacy-root is not a valid argument:

drush migrate-import --all --legacy-root=/Users/awasson/Sites/devdesktop/my-site/sites/default/files

Is there some way I can write that into my settings.php file?

Thanks,
Andrew

I believe the command you want in this case is drush migrate-upgrade and not drush migrate-import. See the example in the blog post.

The migrate-upgrade command runs the Drupal-to-Drupal migrations included with Drupal core. While the migrate-import command is used to run custom migrations. Check out this tutorial for more information on the migrate-upgrade command: https://drupalize.me/tutorial/drupal-drupal-migration-drush?p=2578

Thanks... Ok, so on the configuration side of things not the execution. Good to know. I will scrap what I have and start fresh with that. I'll bet that is the missing link. I'll post back, hopefully with some success!

Thank you, Andrew. Yes, I understood that you were talking to me.

I had to take a break and go back to "real" work for a few days, but I think that what I will do is start again from scratch and see if I can follow the instructions properly this time.

One of the parts that confused me ( and still does ) is how many D8 installations I should have. At the top of the article, it seems to say that I have installed D8 and configured it to be as close to the D6 instance as possible, and then work with that. Then, later on, we go into Drupal Console, which creates a whole new instance of D8, and we are working there.

That seems to be the point where I am most confused.

However, I will use your notes to see if I can get over that.

No, I don't think that I have run into the File Fields problem yet, because I am still earlier in the process.

Thank you,
Brian

You should only need one copy of Drupal 8 installed. The process at a very high-level is:

  • Install Drupal 8 + migrate + Drupal 8 equivalent of any Drupal 6/7 contributed modules. The modules need to be installed, but you don't need to configure anything as configuration should get migrated
  • Take a DB backup
  • Use Migrate Plus + Migrate Tools to generate the configuration that represents a complete migration from your existing Drupal 6/7 site to the new Drupal 8 site
  • Copy the parts of the exported migration configuration that you want to use for your custom migration into the config/install directory of a custom module
  • Revert to a database backup for the Drupal 8 site pre-configuratinon export
  • Install the custom module that contains the custom migration created above so that it's configuration data in config/install is located
  • Run the custom migration
  • Cross your fingers!

Hope that helps to clarify thing as bit.

Ok, I've been playing around with this a bit more and have some follow up info.

1) I haven't been able to actually import/migrate the files correctly. As far as the migration tools are concerned the file migration has been a roaring success with no errors but the files are not actually copied into the sites/default/files directory. Drupal 8 thinks they are there and shows a lovely listing of all ~1,600 files I migrated but the links are all broken.

2) The path to the legacy files is written in the custom migration module here: config/install/migrate_plus.migration.upgrade_d6_file.yml

3) The way to set the legacy path is during the configuration part of the exercise in the shell with the following command: drush migrate-upgrade --configure-only --legacy-root=/PATH/TO/ROOT/DIRECTORY/OF/SITE/ONLY

Note: not to /sites/default/files only to the root directory of the site; Drupal 8 knows where the files are kept within the site.

4) I think there must be a YML file where we can set the appropriate "destination" path so that the files actually get copied somewhere. The migration I tested with was an old D6 site and the migration took quite some time, most of it on the file migration part so I'm not sure where it copied the files to.

That's it for now... Hopefully I can get some more success and finally get the files copied over too.

Cheers
Andrew

Great guide! I'm combining it with another from drupal.org and they wrote about "drush migrate-status". I think my migration problems start with that when I run "drush migrate-upgrade --configure-only" and then "drush migrate-status" nothing comes back in the terminal. Do you have any idea why that might happen?

This is most likely due to a mismatch between the "database key" configured in your migration. And what is present in your settings.php file.

You can use a tool like drush to inspect the migration group configuration entity. Use drush config-list to find the migrate_plus.migration.group* object, and then drush config-get {name} to inspect it. This should show you the "key" that is being used, and you'll want to make sure that in your settings.php file you have matching record in the $databases array.

There's more information about how this all works in our Custom Drupal-to-Drupal Migrations tutorial.

am i assuming correctly that its not possible to migrate data to *existing* (in drupal 8) content types?

like i have content type A in d6 and want to match it to my manually created d8 node type B, i would only add the type key in the respective yml and take the default_value plugin for mapping it to B. i mean thats how its supposed to be done, no?
just that im doing it like this, but the imported "nodes" are broken due to their content type being empty.

what am i doing wrong?

looks like its all been a cache issue. this is highly annoying. migrate was not using the yml files i was editing, but some former active conf instead.

solved.

I tried generating the module as described above (drupal generate:module) and received this error : Error: Call to undefined method Symfony\Component\Console\Formatter\OutputFormatter::escapeTrailingBackslash() in Symfony\Component\Console\Helper\SymfonyQuestionHelper->writePrompt() (line 57 of [...]/vendor/symfony/console/Helper/SymfonyQuestionHelper.php).

What is wrong?

Off hand it looks like this might be an issue with Drupal console. Can you confirm that you've got the latest version installed. And that you're using it with Drupal >= 8.2.x. You might also try asking on the issue queue for the Drupal console project to see if they have any ideas what might cause this issue.

Hi,

First of all thank you for the informative guide.

I followed the instructions but when running 'drush migrate-status', I am getting a lot of db related errors like so:

"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'old_d6.file_managed' doesn't exist: SELECT COUNT(*) AS expression
FROM
(SELECT 1 AS expression
FROM
{file_managed} f
WHERE uri LIKE :db_condition_placeholder_0 ESCAPE '\\') subquery; Array
(
[:db_condition_placeholder_0] => private://%
)
"
The corresponding table is in the d6 site is "files". Do I need to do something to match the table names?

Thank you in advance.
/Hitankar

Off hand it looks like there is something causing this migration to act as though it's coming from the Drupal 7 source insead of a Drupal 8 source. The file_managed table does exist in a Drupal 7 site. Beyond that though it's hard for me to say what might be causing this. Are all the errors from the same table? Or are there other missing tales as well?

Add new comment

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <code class> <ul type> <ol start type> <li> <dl> <dt> <dd><h3 id> <p>
  • Lines and paragraphs break automatically.

About us

Drupalize.Me is the best resource for learning Drupal online. We have an extensive library covering multiple versions of Drupal and we are the most accurate and up-to-date Drupal resource. Learn more