Open dharizza opened 7 years ago
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;
}
}
PR up for review and manual testing for both 6 and 7 migrations.
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:
Missing bundle entity, entity type og_membership_type, entity id og_membership_type_default. A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: og_membership, bundle: og_membership_type_default, field name: og_membership_request
Missing bundle entity, entity type og_membership_type, entity id og_membership_type_default. (core/lib/Drupal/Core/Entity/EntityType.php:910)
I am not sure how to go about contributing to the module. Should I create a pull request, or add a patch as we are used to do on drupal.org ?
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_oggroup).
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 _ogaudience field to not be created: a simple typo in the d7_og_field_instance plugin (tags should be _migrationtags) !
It seems that PRs are enabled on your branch. I will try to create a PR tomorrow with this change and those created in the patch above.
Hi @mradcliffe.
I just created a pull request on your branch.
One thing to note: the og_migrate_migrate_prepare_row hook will not work properly with migrations created using the migrate_upgrade module unless the migration-prefix is set to empty, as any other prefix (even the default one) will alter the ids of all migrations.
I modified og_migrate_migrate_prepare_row to use the plugin id instead of the migration id to make it work with prefixed migration_upgrade exports.
Hello! Is there any work done on an upgrade path from D6 to D8? I saw in https://github.com/Gizra/og/issues/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!