Skip to content
Snippets Groups Projects
Commit 45c4852e authored by Matthew Grasmick's avatar Matthew Grasmick
Browse files

Issue #3360683: Migration routine from Drupal 7 to Drupal 8/9

parent 9c2f1f9b
No related branches found
No related tags found
No related merge requests found
<?php
/**
* @file
* Contains \Drupal\achievements\Plugin\migrate\source.
*/
namespace Drupal\achievements\Plugin\migrate\source;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 7 achievement_storage source from database.
*
* @MigrateSource(
* id = "d7_achievement_storage_source",
* source_module = "achievements"
* )
*/
class AchievementsStorageSource extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('achievement_storage', 'a');
$query->fields('a', [
'achievement_id',
'uid',
'data',
]);
$query->orderBy('uid')->orderBy('achievement_id');
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'achievement_id' => $this->t('The achievement ID.'),
'uid' => $this->t('The ID of the user.'),
'data' => $this->t('The achievement data.'),
];
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['achievement_id']['type'] = 'string';
$ids['uid']['type'] = 'integer';
return $ids;
}
}
<?php
/**
* @file
* Contains \Drupal\achievements\Plugin\migrate\source.
*/
namespace Drupal\achievements\Plugin\migrate\source;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 7 achievement_totals source from database.
*
* @MigrateSource(
* id = "d7_achievement_totals_source",
* source_module = "achievements"
* )
*/
class AchievementsTotalsSource extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('achievement_totals', 'a');
$query->fields('a', [
'uid',
'points',
'unlocks',
'timestamp',
'achievement_id',
]);
$query->orderBy('timestamp');
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'uid' => $this->t('The ID of the user.'),
'points' => $this->t('The amount of points'),
'unlocks' => $this->t('The amount of unlocks.'),
'timestamp' => $this->t('The timestamp of the last change.'),
'achievement_id' => $this->t('The achievement ID.'),
];
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['uid']['type'] = 'integer';
return $ids;
}
}
<?php
/**
* @file
* Contains \Drupal\achievements\Plugin\migrate\source.
*/
namespace Drupal\achievements\Plugin\migrate\source;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 7 achievement_unlocks source from database.
*
* @MigrateSource(
* id = "d7_achievement_unlocks_source",
* source_module = "achievements"
* )
*/
class AchievementsUnlocksSource extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('achievement_unlocks', 'a');
$query->fields('a', [
'achievement_id',
'rank',
'uid',
'timestamp',
'seen',
]);
$query->orderBy('timestamp');
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'achievement_id' => $this->t('The achievement ID.'),
'rank' => $this->t('The rank.'),
'uid' => $this->t('The ID of the user.'),
'timestamp' => $this->t('The unlock timestamp.'),
'seen' => $this->t('Indicates whether the user has seen the notification.'),
];
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['achievement_id']['type'] = 'string';
$ids['uid']['type'] = 'integer';
return $ids;
}
}
id: d7_achievement_storage
label: Drupal 7 Achievement Storage.
migration_tags:
- Drupal 7
source:
plugin: d7_achievement_storage_source
track_changes: true
process:
achievement_id: achievement_id
uid: uid
data: data
destination:
plugin: table
table_name: achievement_storage
id_fields:
achievement_id:
type: string
uid:
type: integer
fields:
achievement_id: achievement_id
uid: uid
data: data
migration_dependencies:
required:
- d7_user
id: d7_achievement_totals
label: Drupal 7 Achievement Totals.
migration_tags:
- Drupal 7
source:
plugin: d7_achievement_totals_source
track_changes: true
process:
uid: uid
points: points
unlocks: unlocks
timestamp: timestamp
achievement_id: achievement_id
destination:
plugin: table
table_name: achievement_totals
id_fields:
uid:
type: integer
fields:
uid: uid
points: points
unlocks: unlocks
timestamp: timestamp
achievement_id: achievement_id
migration_dependencies:
required:
- d7_user
id: d7_achievement_unlocks
label: Drupal 7 Achievement Unlocks.
migration_tags:
- Drupal 7
source:
plugin: d7_achievement_unlocks_source
track_changes: true
process:
achievement_id: achievement_id
rank: rank
uid: uid
timestamp: timestamp
seen: seen
destination:
plugin: table
table_name: achievement_unlocks
id_fields:
achievement_id:
type: string
uid:
type: integer
fields:
achievement_id: achievement_id
rank: rank
uid: uid
timestamp: timestamp
seen: seen
migration_dependencies:
required:
- d7_user
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment