-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,113 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Ringsted D7 Migration module | ||
|
||
## Module purpose | ||
|
||
The aim of this module is to provide migration of the content from Ringsted.dk D7 version to OS2Web D8. | ||
|
||
## Install | ||
|
||
1. Module is part of the repository, and can be installed: | ||
``` | ||
drush en ringsted_d7_migration | ||
``` | ||
2. Create separate Database and import D7 version of the site there. Database must be defined in **settings.php** file (next to the default one): | ||
``` | ||
$databases['default']['default'] = array ( | ||
... | ||
); | ||
|
||
// Describe migration database. | ||
$databases['migrate']['default'] = array ( | ||
'database' => '[db_name]', | ||
'username' => '[db_user]', | ||
'password' => '[db_password]', | ||
'prefix' => '', | ||
'host' => '[db_host]', | ||
'port' => '', | ||
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', | ||
'driver' => 'mysql', | ||
); | ||
``` | ||
## Migrate quick run | ||
Run the entire migration process with single command: | ||
``` | ||
cd web | ||
sh ./modules/custom/ringsted_d7_migration/scripts/migrate.sh | ||
``` | ||
## Migrate process details for manual run | ||
The recommended usage migrate process is via Drush: | ||
Read more about the Drush commands for Migrate API on [Migrate tools](https://www.drupal.org/project/migrate_tool). | ||
* Migrate section terms: | ||
``` | ||
drush migrate:import ringsted_d7_taxonomy_section | ||
``` | ||
* Migrate News: | ||
``` | ||
drush migrate:import ringsted_d7_node_news | ||
``` | ||
* Migrate Postlister: | ||
``` | ||
drush migrate:import ringsted_d7_node_postlister | ||
``` | ||
## Useful hints | ||
When changing migration definition in **.yml** files, import the changes with: | ||
``` | ||
drush cim --partial --source=modules/custom/ringsted_d7_migration/config/install -y | ||
``` | ||
If migration stopped with an error, it might need to be reset, e.g.: | ||
``` | ||
drush migrate:reset [migation_name] | ||
``` | ||
Instead of migrating/importing all entities, it is faster to do development with importing only few entities. Use **limit** flag: | ||
``` | ||
drush migrate:import [migation_name] --limit=5 | ||
``` | ||
By default each migration run will import only new entities, but sometimes you want to overwrite what you already have instead of importing new ones. That can be done with **update** flag: | ||
``` | ||
drush migrate:import [migation_name] --update | ||
``` | ||
Use it with **limit** flag to force update previously imported entities: | ||
``` | ||
drush migrate:import [migation_name] --limit=5 --update | ||
``` | ||
## Contribution | ||
Project is opened for new features and os course bugfixes. | ||
If you have any suggestion or you found a bug in project, you are very welcome | ||
to create an issue in github repository issue tracker. | ||
For issue description there is expected that you will provide clear and | ||
sufficient information about your feature request or bug report. | ||
### Code review policy | ||
See [OS2Web code review policy](https://github.com/OS2Web/docs#code-review) | ||
### Git name convention | ||
See [OS2Web git name convention](https://github.com/OS2Web/docs#git-guideline) |
103 changes: 103 additions & 0 deletions
103
...tom/ringsted_d7_migration/config/install/migrate_plus.migration.ringsted_d7_node_news.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
id: ringsted_d7_node_news | ||
label: Ringsted D7 Node News | ||
migration_group: ringsted_d7 | ||
migration_tags: | ||
- Drupal 7 | ||
- Content | ||
deriver: Drupal\node\Plugin\migrate\D7NodeDeriver | ||
source: | ||
plugin: d7_node | ||
node_type: news | ||
track_changes: true | ||
process: | ||
# If you are using this file to build a custom migration consider removing | ||
# the nid and vid fields to allow incremental migrations. | ||
# In D7, nodes always have a tnid, but it's zero for untranslated nodes. | ||
# We normalize it to equal the nid in that case. | ||
# @see \Drupal\node\Plugin\migrate\source\d7\Node::prepareRow(). | ||
type: | ||
plugin: default_value | ||
default_value: os2web_news | ||
langcode: | ||
plugin: default_value | ||
source: language | ||
default_value: 'und' | ||
title: title | ||
field_os2web_news_heading: title | ||
status: status | ||
created: created | ||
changed: changed | ||
#promote: promote | ||
sticky: sticky | ||
field_os2web_news_article_author: field_author | ||
field_os2web_news_article_date: | ||
- plugin: skip_row_if_old_news | ||
index: 0 | ||
source: field_date | ||
- plugin: sub_process | ||
source: field_date | ||
process: | ||
value: | ||
plugin: format_date | ||
from_format: 'Y-m-d H:i:s' | ||
to_format: 'Y-m-d\TH:i:s' | ||
from_timezone: 'Europe/Copenhagen' | ||
source: value | ||
field_os2web_news_description: | ||
- plugin: sub_process | ||
source: body | ||
process: | ||
value: value | ||
format: | ||
plugin: default_value | ||
default_value: 'wysiwyg_tekst' | ||
field_os2web_news_section: | ||
- plugin: sub_process | ||
source: field_taxonomy_subject_area | ||
process: | ||
target_id: | ||
plugin: migration_lookup | ||
migration: ringsted_d7_taxonomy_section | ||
source: tid | ||
field_os2web_news_intro: field_teaser | ||
migrate_file_url_source: | ||
- plugin: extract | ||
source: field_image_thumbnail | ||
default: '' | ||
index: | ||
- 0 | ||
- plugin: callback | ||
callable: | ||
- 'Drupal\ringsted_d7_migration\Utility\MigrationHelper' | ||
- getFileDownloadUrl | ||
migrate_file_url_destination: | ||
- plugin: extract | ||
source: field_image_thumbnail | ||
default: '' | ||
index: | ||
- 0 | ||
- plugin: callback | ||
callable: | ||
- 'Drupal\ringsted_d7_migration\Utility\MigrationHelper' | ||
- generateFileDestinationPath | ||
migrate_file_fid: | ||
- plugin: skip_on_empty | ||
method: process | ||
source: '@migrate_file_url_source' | ||
message: 'Image is missing' | ||
- plugin: file_copy | ||
source: | ||
- '@migrate_file_url_source' | ||
- '@migrate_file_url_destination' | ||
- plugin: callback | ||
callable: | ||
- 'Drupal\ringsted_d7_migration\Utility\MigrationHelper' | ||
- createFileManaged | ||
field_os2web_news_primaryimage/target_id: '@migrate_file_fid' | ||
field_os2web_news_primaryimage/alt: field_image_description/0/value | ||
destination: | ||
plugin: entity:node | ||
migration_dependencies: | ||
required: | ||
- ringsted_d7_taxonomy_section | ||
optional: {} |
63 changes: 63 additions & 0 deletions
63
...ngsted_d7_migration/config/install/migrate_plus.migration.ringsted_d7_node_postlister.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
id: ringsted_d7_node_postlister | ||
label: Ringsted D7 Node Postlister | ||
migration_group: ringsted_d7 | ||
migration_tags: | ||
- Drupal 7 | ||
- Content | ||
deriver: Drupal\node\Plugin\migrate\D7NodeDeriver | ||
source: | ||
plugin: d7_node | ||
node_type: postliste | ||
track_changes: true | ||
process: | ||
# If you are using this file to build a custom migration consider removing | ||
# the nid and vid fields to allow incremental migrations. | ||
# In D7, nodes always have a tnid, but it's zero for untranslated nodes. | ||
# We normalize it to equal the nid in that case. | ||
# @see \Drupal\node\Plugin\migrate\source\d7\Node::prepareRow(). | ||
type: | ||
plugin: default_value | ||
default_value: os2web_postlister | ||
langcode: | ||
plugin: default_value | ||
source: language | ||
default_value: 'und' | ||
title: title | ||
field_os2web_postlister_heading: field_teaser | ||
status: status | ||
created: | ||
plugin: skip_row_if_old | ||
skipOlderThanDate: "2021-01-01" | ||
source: created | ||
message: "Skipped old content" | ||
changed: changed | ||
#promote: promote | ||
sticky: sticky | ||
field_os2web_postlister_descript: | ||
- plugin: sub_process | ||
source: body | ||
process: | ||
value: value | ||
format: | ||
plugin: default_value | ||
default_value: 'wysiwyg_tekst' | ||
field_os2web_postlister_kle/target_id: | ||
- plugin: callback | ||
callable: | ||
- 'Drupal\ringsted_d7_migration\Utility\MigrationHelper' | ||
- findPostlisterKleTerm | ||
source: nid | ||
field_os2web_postlister_section: | ||
- plugin: sub_process | ||
source: field_taxonomy_subject_area | ||
process: | ||
target_id: | ||
plugin: migration_lookup | ||
migration: ringsted_d7_taxonomy_section | ||
source: tid | ||
destination: | ||
plugin: entity:node | ||
migration_dependencies: | ||
required: | ||
- ringsted_d7_taxonomy_section | ||
optional: {} |
36 changes: 36 additions & 0 deletions
36
...gsted_d7_migration/config/install/migrate_plus.migration.ringsted_d7_taxonomy_section.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
id: ringsted_d7_taxonomy_section | ||
label: Ballerup D7 Taxonomy section | ||
migration_group: ringsted_d7 | ||
migration_tags: | ||
- Drupal 7 | ||
deriver: Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver | ||
source: | ||
plugin: d7_taxonomy_term | ||
bundle: subject_area | ||
track_changes: true | ||
process: | ||
vid: | ||
plugin: default_value | ||
default_value: os2web_sektion | ||
name: name | ||
weight: weight | ||
# Only attempt to stub real (non-zero) parents. | ||
parent_id: | ||
- | ||
plugin: skip_on_empty | ||
method: process | ||
source: parent | ||
- | ||
plugin: migration_lookup | ||
migration: ringsted_d7_taxonomy_section | ||
parent: | ||
plugin: default_value | ||
default_value: 0 | ||
source: '@parent_id' | ||
changed: timestamp | ||
langcode: language | ||
destination: | ||
plugin: entity:taxonomy_term | ||
migration_dependencies: | ||
required: {} | ||
optional: {} |
11 changes: 11 additions & 0 deletions
11
.../custom/ringsted_d7_migration/config/install/migrate_plus.migration_group.ringsted_d7.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
langcode: da | ||
status: true | ||
dependencies: | ||
enforced: | ||
module: | ||
- ringsted_d7_migration | ||
id: ringsted_d7 | ||
label: 'Ringsted D7 Content' | ||
description: 'Ringsted.dk D7 content import' | ||
source_type: 'Ringsted.dk Database' | ||
module: null |
11 changes: 11 additions & 0 deletions
11
web/modules/custom/ringsted_d7_migration/ringsted_d7_migration.info.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Ringsted.dk D7 Migration | ||
description: Custom migration module for migrating data from Ringsted.dk Drupal 7 site. | ||
package: 'Bellcom' | ||
type: module | ||
core: 8.x | ||
core_version_requirement: ^8 || ^9 | ||
dependencies: | ||
- migrate | ||
- migrate_drupal | ||
- migrate_plus | ||
- os2web_news |
1 change: 1 addition & 0 deletions
1
web/modules/custom/ringsted_d7_migration/ringsted_d7_migration.module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php |
21 changes: 21 additions & 0 deletions
21
web/modules/custom/ringsted_d7_migration/scripts/migrate.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
echo "Migration started" | ||
|
||
echo "Importing new import configuration" | ||
drush cim --partial --source=modules/custom/ringsted_d7_migration/config/install -y | ||
echo "Configuration imported" | ||
|
||
echo "Migration ringsted_d7_taxonomy_section - START" | ||
drush migrate:import ringsted_d7_taxonomy_section | ||
echo "Migration ringsted_d7_taxonomy_section - END" | ||
|
||
echo "Migration ringsted_d7_node_news - START" | ||
drush migrate:import ringsted_d7_node_news | ||
echo "Migration ringsted_d7_node_news - END" | ||
|
||
echo "Migration ringsted_d7_node_postlister - START" | ||
drush migrate:import ringsted_d7_node_postlister | ||
echo "Migration ringsted_d7_node_postlister - END" | ||
|
||
echo "Migration finished" |
Oops, something went wrong.