7

I don't want to make a full migration. I want to migrate only and solely Nodes (preferably with their Metatag metadata as well). Not Views, Not Panels, not Contexts, not URL redirects - Only Nodes...

I ask this after encountering some troubles in full D7>>D8 upgrade and when using the Drupal Upgrade module (I even opened a thread regarding it here in DA). Therefore, I am looking for ways to make only a partial migration, or to make migration in parts.

Is it possible regarding to nodes?

  • 1
    i would suggest exporting to XML and using Feeds for import, but since "This module is currently being ported to Drupal 8, but is not usable yet." it is not an option. Yet. – Mołot Dec 30 '15 at 22:43
  • take a look at drupal.org/project/bundle_copy it exports only the structure not the data and then use feeds module to export import data – Bala Dec 31 '15 at 4:12
  • @Bala, have you tried it regarding D7>>D8 migration? Or at least, you think it is most likely to work? – user16289 Jan 1 '16 at 14:17
  • @benos not yet! I'm suggesting the option, it's upto you – Bala Jan 1 '16 at 14:22
9

You don't need to do a full migration. You can initialize the Upgrade process by connecting to the old site and it will create migrations. Then you can, instead of executing them automatically, run just some of them with the UI provided by the upgrade_tools project ( I think?).

However, migrations have dependencies. To be able to run the node migration, by default you have to run a few others, e.g. users, text formats and also the fields.

You can try to change that by editing the created migrations either with drush cedit or export/import. I believe someone is also working on an UI for it.

You can also customize any mapping and how fields are migrated. The default behavior is that every field and configuration is migrated 1:1 but to be honest, I can't imagine that's what most sites will want to do. Instead, I imagine they build a new D8 site and then import the content.

See the migration documentation. There are also plenty of blog posts available already around that topic but it's not a trivial thing to do.

Alternatively, you can try to export/import your content, as mentioned in the Comments, Feeds is not quite ready yet, but you could use a views export and import by writing some custom code.

| improve this answer | |
  • I am sorry to use that I had a serious problem (which is lasting till now) with the Drupal Upgrade module and it seems I just can't use it. I have described it in detail here: drupal.stackexchange.com/questions/185364/… – user16289 Dec 31 '15 at 0:10
  • Berdir, you wrote "I imagine they build a new D8 site and then import the content." Well, it sounds great to me, Is there a way to import content directly? I mean is there a bot who is rewriting all the nodes in a D7 site to a D8 site on the same server, without using the current (seemingly still experimental) modules? – user16289 Dec 31 '15 at 0:13
  • I will now check the links as well but if you could answer here on my question above in your own words it can be fantastic, – user16289 Dec 31 '15 at 0:14
5
+50

Migration is a bit heavy weight for this. In drupal 7 there were some modules for only import/export of content. In drupal 8 I couldn't find any that is ready yet. So I improvised with a bit of code:

I did an export in drupal 7 with views to csv with the help of the module:

views_data_export

In drupal 8 I've used the php-library:

parsecsv-for-php

And this code:

require_once('parsecsv.lib.php');
$csv = new parseCSV();
$csv->auto($filepath);
foreach ($csv->data as $key => $row) {
  $node = entity_create('node', array('type' => 'article', 'title' => $row['title'], 'uid' => $row['uid']));
  $node->langcode->value = 'en';
  $body = $row['body'];
  $body = str_replace('http://host1.com/', 'http://host2.com/', $body);
  $node->body->value = $body;
  $node->body->format = 'full_html'; 
  ...
  $node->save();
}

The advantage is, that you can make your own adjustment, like replacing paths from drupal 7, or set a fixed language. And you can check if all dependencies are met, for example that the uid is already there.

| improve this answer | |
1

We wanted to skip some content types from migration as Migrate modules in D8 migrate all of them by default. We used hook_migrate_prepare_row to skip the content types in our custom module.

function hook_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {
  // Ignore content types from being migrated.
  if ($migration->id() == 'd6_node_type') {
    $ignore_content_types = array('content_type1', 'content_type2');
    if (in_array($row->getSource()['type'], $ignore_content_types)) {
      return FALSE;
    }
  }

  // Ignoring content of 4 content types.
  $ignore_content_types_content = array('d6_node__content_type1', 'd6_node__content_type2');
  if (in_array($migration->id(), $ignore_content_types_content)) {
    return FALSE;
  }
}

More info. - https://www.drupal.org/node/2641912

You get the list of migration ids using drush migrate-status command and skip them as required.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy