-
Notifications
You must be signed in to change notification settings - Fork 133
Drupal 8 migration path from Drupal 6 & 7 #284
Comments
To my knowledge this is not yet being worked on inside the OG code base so if you are willing you are free to start a PR, that would be really helpful! I know that @claudiu-cristea has been working on a migrate path from D6 to D8 for a client project that uses OG. You could have a look there for inspiration. Here are some of the relevant files: |
Here's code that another developer on my project wrote for a migrate source plugin from D6 OG memberships (the og_uid table) for migrating them to D8 Membership entities. It's not complete, as it assumes there aren't any roles other than member and admin, but it's a good starting point :) <?php
namespace Drupal\PROJECT_migrate\Plugin\migrate\source;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Source plugin for OG user membership data.
*
* Allows limiting to a particular group type with the 'node_type' configuration
* option.
*
* @MigrateSource(
* id = "og_memberships"
* )
*/
class OgMembership extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
// Get all D6 og membership records.
$query = $this->select('og_uid', 'ou')
->fields('ou', ['nid', 'og_role', 'is_active', 'is_admin', 'uid', 'created', 'changed', 'last_visit']);
$query->condition('ou.nid', 0, '<>');
$query->condition('ou.uid', 0, '<>');
if (isset($this->configuration['node_type'])) {
$query->innerJoin('node', 'n', 'ou.nid = n.nid');
$query->condition('n.type', $this->configuration['node_type']);
}
$query->orderBy('ou.created');
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'nid' => $this->t('The OG node ID.'),
'og_role' => $this->t('The OG role.'),
'is_active' => $this->t('Whether membership is active.'),
'is_admin' => $this->t('Whether membership is admin.'),
'uid' => $this->t('The user ID.'),
'created' => $this->t('Membership creation time.'),
'changed' => $this->t('Membership changed time.'),
'last_visit' => $this->t('Membership last_visit time.'),
];
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['nid']['type'] = 'integer';
$ids['uid']['type'] = 'integer';
return $ids;
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
if (parent::prepareRow($row) === FALSE) {
return FALSE;
}
// Add group type (network or microsite).
$query = $this->select('node', 'n');
$og_group_type = $query->fields('n', ['type'])
->condition('n.nid', $row->getSourceProperty('nid'))
->execute()
->fetchField();
$row->setSourceProperty("og_group_type", $og_group_type);
// Add admin role names.
$og_roles = [];
if ($row->getSourceProperty('is_admin')) {
$og_roles[] = 'node-' . $og_group_type . '-administrator';
}
$row->setSourceProperty("og_roles", $og_roles);
return TRUE;
}
} |
…, membership and roles
PR up for review and manual testing for both 6 and 7 migrations. |
…, membership and roles
I am testing out the D7 migration on a fairly simple use case (one group entity type, one content entity type and one group membership type) using the og_migrate module. Here are some notes:
I am not sure how to go about contributing to the module. Attached is a patch that tries to address the issues 1 and 2 and fixes some other minor issues (module name and package name, and a typo in d7_og_group). |
Thank you, @semiaddict . I am not sure either the best way of contributing on github. It would be much easier on drupal.org with the familiar patch system where anyone can contribute on an issue rather than only one person being able to contribute code on a Pull Request (without lots of finagling). I can take a look at your zip file over on my branch, but if I forget to do so, then there are two options:
|
Thank you @mradcliffe. I found what was causing the og_audience field to not be created: a simple typo in the d7_og_field_instance plugin (tags should be migration_tags) ! It seems that PRs are enabled on your branch. |
Hi @mradcliffe. I just created a pull request on your branch.
|
…ation and og field migration * Alter the default membership type bundle name in field migration rows * Fix some typos in migration plugins and improved migration module info * Use the source plugin id instead of the migration id in hook_migrate_prepare_row * Replace two migration ids with their corresponding source plugin ids in og_migrate_migrate_prepare_row * Fixed comments in hook_migrate_prepare_row * Fix the OgFieldD7MigrateTest kernel test * Add dependencies in the OgFieldD7MigrateTest kernel test * Skip migrating the og_membership_request field on the default group membership type * Fix a typo in og_migrate_migrate_prepare_row * Fix and improve handling default membership type in og_migrate_migrate_prepare_row * Fix a couple of coding standard issues and add assetions for the form and view displays of the default membership type
…og group migrations
…s based on travis run
Hello!
Is there any work done on an upgrade path from D6 to D8? I saw in #240 it may be required to go stable.
If it's still not implemented, I'd try to help if you point me in the right direction.
Thanks!
The text was updated successfully, but these errors were encountered: