Skip to content

Commit

Permalink
Adding migrate single script to run
Browse files Browse the repository at this point in the history
  • Loading branch information
stankut committed Apr 22, 2021
1 parent 22e9838 commit 8cf2aaa
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 10 deletions.
9 changes: 8 additions & 1 deletion web/modules/custom/ballerup_d7_migration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ $databases['migrate']['default'] = array (
);
```
## Migrate process
## Migrate quick run
Run the entire migration process with single command:
```
cd web
sh ./modules/custom/ballerup_d7_migration/scripts/migrate.sh
```
## Migrate process details for manual run
The recommended usage migrate process is via Drush:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
source:
plugin: d7_node
node_type: contact_box
track_changes: true
process:
migrate_publish:
plugin: skip_on_empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
source:
plugin: d7_node
node_type: institution_page
track_changes: true
process:
name:
plugin: substr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
source:
plugin: d7_node
node_type: gallery_slide
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.
Expand Down Expand Up @@ -35,7 +36,7 @@ process:
status: status
created: created
changed: changed
promote: promote
#promote: promote
sticky: sticky
path/pathauto:
plugin: default_value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
source:
plugin: d7_node
node_type: info_page
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.
Expand Down Expand Up @@ -36,7 +37,7 @@ process:
status: status
created: created
changed: changed
promote: promote
#promote: promote
sticky: sticky
field_os2web_page_description:
- plugin: sub_process
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
source:
plugin: d7_node
node_type: institution_page
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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.
Expand Down Expand Up @@ -36,7 +37,7 @@ process:
status: status
created: created
changed: changed
promote: promote
#promote: promote
sticky: sticky
field_os2web_news_article_author: field_newsarticle_author
field_os2web_news_article_date:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
source:
plugin: d7_node
node_type: info_page
track_changes: true
process:
field_os2web_accordion_heading:
-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
source:
plugin: d7_node
node_type: gallery_slide
track_changes: true
process:
field_os2web_iframe_code:
-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ deriver: Drupal\node\Plugin\migrate\D7NodeDeriver
source:
plugin: d7_node
node_type: institution_page
track_changes: true
process:
vid:
plugin: default_value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ deriver: Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver
source:
plugin: d7_taxonomy_term
bundle: section
track_changes: true
process:
vid:
plugin: default_value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ deriver: Drupal\taxonomy\Plugin\migrate\D7TaxonomyTermDeriver
source:
plugin: d7_taxonomy_term
bundle: tags
track_changes: true
process:
vid:
plugin: default_value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ migration_tags:
class: Drupal\user\Plugin\migrate\User
source:
plugin: d7_user
track_changes: true
process:
# If you are using this file to build a custom migration,
# consider removing the uid field to allow
Expand Down
56 changes: 56 additions & 0 deletions web/modules/custom/ballerup_d7_migration/scripts/migrate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh

echo "Importing new import configuration"
drush cim --partial --source=modules/custom/ballerup_d7_migration/config/install -y
echo "Configuration imported"

echo "Migration users - START"
drush migrate:import ballerup_d7_user
echo "Migration users - END"

echo "Migration ballerup_d7_taxonomy_section - START"
drush migrate:import ballerup_d7_taxonomy_section
echo "Migration ballerup_d7_taxonomy_section - END"

echo "Migration ballerup_d7_taxonomy_tags - START"
drush migrate:import ballerup_d7_taxonomy_tags
echo "Migration ballerup_d7_taxonomy_tags - END"

echo "Migration os2web_borgerdk_articles_import - START"
drush migrate:import os2web_borgerdk_articles_import
echo "Migration os2web_borgerdk_articles_import - END"

echo "Migration ballerup_d7_contact_box - START"
drush migrate:import ballerup_d7_contact_box
echo "Migration ballerup_d7_contact_box - END"

echo "Migration ballerup_d7_paragraph_iframe - START"
drush migrate:import ballerup_d7_paragraph_iframe
echo "Migration ballerup_d7_paragraph_iframe - END"

echo "Migration ballerup_d7_node_gallery_slide - START"
drush migrate:import ballerup_d7_node_gallery_slide
echo "Migration ballerup_d7_node_gallery_slide - END"

echo "Migration ballerup_d7_node_institution_page - START"
drush migrate:import ballerup_d7_node_institution_page
echo "Migration ballerup_d7_node_institution_page - END"

echo "Migration ballerup_d7_node_news - START"
drush migrate:import ballerup_d7_node_news
echo "Migration ballerup_d7_node_news - END"

echo "Migration ballerup_d7_paragraph_accordion - START"
drush migrate:import ballerup_d7_paragraph_accordion
echo "Migration ballerup_d7_paragraph_accordion - END"

echo "Migration ballerup_d7_node_indholdside - START"
drush migrate:import ballerup_d7_node_indholdside
echo "Migration ballerup_d7_node_indholdside - END"

echo "Execuing custom script [1/2] - Fix publish status"
drush scr modules/custom/ballerup_d7_migration/scripts/migrate_fix_publish_status.php
echo "Execuing custom script [2/2] - Remove inline picutres"
drush scr modules/custom/ballerup_d7_migration/scripts/remove_inline_pictures.php

echo "Migration complete visit URL '/admin/config/system/delete-orphans' to delete the orphaned paragraphs"
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@
// Find corresponding migrate_nid
if (isset($migrate_nids[$nid])) {
$migrateNid = $migrate_nids[$nid];
print_r("Inspecting $nid : $migrateNid");
print_r(PHP_EOL);
// print_r("Inspecting $nid : $migrateNid");
// print_r(PHP_EOL);

// Find migrate node status
$status = $migrateNodeStatus[$migrateNid];
print_r("Status is $status");
print_r(PHP_EOL);
// print_r("Status is $status");
// print_r(PHP_EOL);

// If published.
if ($status) {
print_r("Setting $nid published");
print_r(PHP_EOL);
// pint_r("Setting $nid published");
// print_r(PHP_EOL);

$node = Node::load($nid);
$node->setPublished(TRUE);
Expand Down

0 comments on commit 8cf2aaa

Please sign in to comment.