Adds migration configs.
This commit is contained in:
@@ -0,0 +1,95 @@
|
|||||||
|
# Migration configuration for importing basic pages.
|
||||||
|
id: cdesai_basic_pages
|
||||||
|
label: Import Basic Pages from CSV
|
||||||
|
migration_group: CDESAI
|
||||||
|
|
||||||
|
source:
|
||||||
|
# The custom CSV source plugin will fetch the source path from configs.
|
||||||
|
# Upload source files at /admin/config/development/cdesai/migrate.
|
||||||
|
plugin: 'cdesai_migrate_csv'
|
||||||
|
source_config_key: cdesai_migrate_basic_pages_source
|
||||||
|
|
||||||
|
delimiter: ','
|
||||||
|
enclosure: '"'
|
||||||
|
header_offset: 0
|
||||||
|
|
||||||
|
ids:
|
||||||
|
- page
|
||||||
|
|
||||||
|
process:
|
||||||
|
langcode: en
|
||||||
|
moderation_state: draft
|
||||||
|
title: title
|
||||||
|
|
||||||
|
uid:
|
||||||
|
plugin: default_value
|
||||||
|
default_value: 1
|
||||||
|
|
||||||
|
field_content/target_id:
|
||||||
|
# Skips a row if skip_migration property is set to TRUE.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: skip_migration
|
||||||
|
value: 'TRUE'
|
||||||
|
method: row
|
||||||
|
-
|
||||||
|
plugin: migration_lookup
|
||||||
|
migration: cdesai_paragraph_parents
|
||||||
|
no_stub: true
|
||||||
|
source: page
|
||||||
|
-
|
||||||
|
plugin: extract
|
||||||
|
index:
|
||||||
|
- '0'
|
||||||
|
field_content/target_revision_id:
|
||||||
|
-
|
||||||
|
plugin: migration_lookup
|
||||||
|
migration: cdesai_paragraph_parents
|
||||||
|
no_stub: true
|
||||||
|
source: page
|
||||||
|
-
|
||||||
|
plugin: extract
|
||||||
|
index:
|
||||||
|
- 1
|
||||||
|
|
||||||
|
field_category:
|
||||||
|
# Do not process further if the category value is empty.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: category
|
||||||
|
value: ''
|
||||||
|
method: process
|
||||||
|
|
||||||
|
# The plugin looks up for an exiting term based on the value_key property.
|
||||||
|
# If no matching term is found, it creates one on the fly.
|
||||||
|
-
|
||||||
|
plugin: entity_generate
|
||||||
|
source: category
|
||||||
|
entity_type: taxonomy_term
|
||||||
|
bundle_key: vid
|
||||||
|
bundle: category
|
||||||
|
value_key: name
|
||||||
|
ignore_case: true
|
||||||
|
|
||||||
|
field_legacy_url: legacy_url
|
||||||
|
|
||||||
|
type:
|
||||||
|
plugin: default_value
|
||||||
|
default_value: basic_page
|
||||||
|
|
||||||
|
destination:
|
||||||
|
plugin: 'entity:node'
|
||||||
|
|
||||||
|
# make sure these migration execute before running current migration
|
||||||
|
migration_dependencies:
|
||||||
|
required:
|
||||||
|
- cdesai_paragraphs
|
||||||
|
- cdesai_paragraph_parents
|
||||||
|
|
||||||
|
# use forced module dependency so uninstall/reinstall works properly
|
||||||
|
dependencies:
|
||||||
|
enforced:
|
||||||
|
module:
|
||||||
|
- cdesai_migrate
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# Migration configuration for attaching paragraphs to parent paragraphs (row).
|
||||||
|
id: cdesai_paragraph_parents
|
||||||
|
label: 'Parent (Row) Paragraphs'
|
||||||
|
migration_group: CDESAI
|
||||||
|
|
||||||
|
source:
|
||||||
|
# Upload source files at /admin/config/development/cdesai/migrate.
|
||||||
|
plugin: cdesai_paragraph_migrate_source
|
||||||
|
|
||||||
|
process:
|
||||||
|
langcode: en
|
||||||
|
field_bundles/target_id:
|
||||||
|
# Skips a row if skip_migration property is set to TRUE.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: skip_migration
|
||||||
|
value: 'TRUE'
|
||||||
|
method: row
|
||||||
|
# Skips a row if scrapped property is set to FALSE.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: scrapped
|
||||||
|
value: 'FALSE'
|
||||||
|
method: row
|
||||||
|
-
|
||||||
|
plugin: migration_lookup
|
||||||
|
migration: cdesai_paragraphs
|
||||||
|
no_stub: true
|
||||||
|
source: page
|
||||||
|
-
|
||||||
|
plugin: extract
|
||||||
|
index:
|
||||||
|
- '0'
|
||||||
|
field_bundles/target_revision_id:
|
||||||
|
-
|
||||||
|
plugin: migration_lookup
|
||||||
|
migration: cdesai_paragraphs
|
||||||
|
no_stub: true
|
||||||
|
source: page
|
||||||
|
-
|
||||||
|
plugin: extract
|
||||||
|
index:
|
||||||
|
- '1'
|
||||||
|
|
||||||
|
destination:
|
||||||
|
plugin: 'entity_reference_revisions:paragraph'
|
||||||
|
default_bundle: row
|
||||||
|
|
||||||
|
# make sure these migration execute before running current migration
|
||||||
|
migration_dependencies:
|
||||||
|
required:
|
||||||
|
- cdesai_paragraphs
|
||||||
|
|
||||||
|
# use forced module dependency so uninstall/reinstall works properly
|
||||||
|
dependencies:
|
||||||
|
enforced:
|
||||||
|
module:
|
||||||
|
- cdesai_migrate
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# Migration configuration for importing content paragraphs.
|
||||||
|
id: cdesai_paragraphs
|
||||||
|
label: Import Content Paragraphs from Text File Archive
|
||||||
|
migration_group: CDESAI
|
||||||
|
|
||||||
|
source:
|
||||||
|
# Upload source files at /admin/config/development/cdesai/migrate.
|
||||||
|
plugin: cdesai_paragraph_migrate_source
|
||||||
|
|
||||||
|
process:
|
||||||
|
langcode: en
|
||||||
|
|
||||||
|
field_body/value:
|
||||||
|
# Skips a row if skip_migration property is set to TRUE.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: skip_migration
|
||||||
|
value: 'TRUE'
|
||||||
|
method: row
|
||||||
|
# Skips a row if scrapped property is set to FALSE.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: scrapped
|
||||||
|
value: 'FALSE'
|
||||||
|
method: row
|
||||||
|
# Uses the custom process plugin to extract paragraph contents from a text file.
|
||||||
|
-
|
||||||
|
plugin: extract_file_contents
|
||||||
|
source: content_file
|
||||||
|
|
||||||
|
field_body/format:
|
||||||
|
plugin: default_value
|
||||||
|
default_value: rich_text
|
||||||
|
|
||||||
|
destination:
|
||||||
|
plugin: 'entity_reference_revisions:paragraph'
|
||||||
|
default_bundle: basic
|
||||||
|
|
||||||
|
# use forced module dependency so uninstall/reinstall works properly
|
||||||
|
dependencies:
|
||||||
|
enforced:
|
||||||
|
module:
|
||||||
|
- cdesai_migrate
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
# Migration configuration for importing profile pages.
|
||||||
|
id: cdesai_profile_pages
|
||||||
|
label: Import Profile Pages from CSV
|
||||||
|
migration_group: CDESAI
|
||||||
|
|
||||||
|
source:
|
||||||
|
# The custom CSV source plugin will fetch the source path from configs.
|
||||||
|
# Upload source files at /admin/config/development/cdesai/migrate.
|
||||||
|
plugin: 'cdesai_migrate_csv'
|
||||||
|
source_config_key: cdesai_migrate_profile_pages_source
|
||||||
|
|
||||||
|
delimiter: ','
|
||||||
|
enclosure: '"'
|
||||||
|
header_offset: 0
|
||||||
|
|
||||||
|
ids:
|
||||||
|
- page
|
||||||
|
|
||||||
|
process:
|
||||||
|
langcode: en
|
||||||
|
moderation_state: draft
|
||||||
|
title: title
|
||||||
|
field_legacy_url: legacy_url
|
||||||
|
field_year_birth: year_birth
|
||||||
|
field_year_death: year_death
|
||||||
|
|
||||||
|
uid:
|
||||||
|
plugin: default_value
|
||||||
|
default_value: 1
|
||||||
|
|
||||||
|
body/value:
|
||||||
|
# Skips a row if skip_migration property is set to TRUE.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: skip_migration
|
||||||
|
value: 'TRUE'
|
||||||
|
method: row
|
||||||
|
# Skips a row if scrapped property is set to FALSE.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: scrapped
|
||||||
|
value: 'FALSE'
|
||||||
|
method: row
|
||||||
|
-
|
||||||
|
plugin: migration_lookup
|
||||||
|
migration: cdesai_paragraphs
|
||||||
|
no_stub: true
|
||||||
|
source: page
|
||||||
|
-
|
||||||
|
plugin: extract_cdesai_migrate_paragraph
|
||||||
|
|
||||||
|
field_body/format:
|
||||||
|
plugin: default_value
|
||||||
|
default_value: rich_text
|
||||||
|
|
||||||
|
field_position:
|
||||||
|
# Do not process further if the position value is empty.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: position
|
||||||
|
value: ''
|
||||||
|
method: process
|
||||||
|
|
||||||
|
# The plugin looks up for an exiting term based on the value_key property.
|
||||||
|
# If no matching term is found, it creates one on the fly.
|
||||||
|
-
|
||||||
|
plugin: entity_generate
|
||||||
|
source: position
|
||||||
|
entity_type: taxonomy_term
|
||||||
|
bundle_key: vid
|
||||||
|
bundle: position
|
||||||
|
value_key: name
|
||||||
|
ignore_case: true
|
||||||
|
|
||||||
|
field_agency:
|
||||||
|
# Do not process further if the position value is empty.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: agency
|
||||||
|
value: ''
|
||||||
|
method: process
|
||||||
|
|
||||||
|
# The plugin looks up for an exiting term based on the value_key property.
|
||||||
|
# If no matching term is found, it creates one on the fly.
|
||||||
|
-
|
||||||
|
plugin: entity_generate
|
||||||
|
source: agency
|
||||||
|
entity_type: taxonomy_term
|
||||||
|
bundle_key: vid
|
||||||
|
bundle: agency
|
||||||
|
value_key: name
|
||||||
|
ignore_case: true
|
||||||
|
|
||||||
|
field_years_in_office:
|
||||||
|
-
|
||||||
|
plugin: skip_on_empty
|
||||||
|
source: years_in_office
|
||||||
|
method: process
|
||||||
|
message: 'Row does not contain years_in_office.'
|
||||||
|
-
|
||||||
|
plugin: explode
|
||||||
|
delimiter: ','
|
||||||
|
-
|
||||||
|
plugin: callback
|
||||||
|
callable: trim
|
||||||
|
|
||||||
|
field_media/target_id:
|
||||||
|
# Skips a row if has_images property is set to FALSE.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: has_images
|
||||||
|
value: 'FALSE'
|
||||||
|
method: row
|
||||||
|
-
|
||||||
|
plugin: skip_on_empty
|
||||||
|
method: row
|
||||||
|
message: 'Cannot import image file with an empty url.'
|
||||||
|
-
|
||||||
|
plugin: migration_lookup
|
||||||
|
migration: cdesai_profile_pages_media_items
|
||||||
|
source: page
|
||||||
|
|
||||||
|
type:
|
||||||
|
plugin: default_value
|
||||||
|
default_value: profile
|
||||||
|
|
||||||
|
destination:
|
||||||
|
plugin: 'entity:node'
|
||||||
|
|
||||||
|
# make sure these migration execute before running current migration
|
||||||
|
migration_dependencies:
|
||||||
|
required:
|
||||||
|
- cdesai_profile_pages_media_items
|
||||||
|
- cdesai_basic_pages
|
||||||
|
|
||||||
|
# use forced module dependency so uninstall/reinstall works properly
|
||||||
|
dependencies:
|
||||||
|
enforced:
|
||||||
|
module:
|
||||||
|
- cdesai_migrate
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
# Migration configuration for importing image files.
|
||||||
|
id: cdesai_profile_pages_image_files
|
||||||
|
label: Import Profile Page Files
|
||||||
|
migration_group: CDESAI_MEDIA
|
||||||
|
|
||||||
|
source:
|
||||||
|
# The custom CSV source plugin will fetch the source path from configs.
|
||||||
|
# Upload source files at /admin/config/development/cdesai/migrate.
|
||||||
|
plugin: 'cdesai_migrate_csv'
|
||||||
|
source_config_key: cdesai_migrate_profile_pages_source
|
||||||
|
|
||||||
|
delimiter: ','
|
||||||
|
enclosure: '"'
|
||||||
|
header_offset: 0
|
||||||
|
|
||||||
|
constants:
|
||||||
|
DRUPAL_FILE_DIRECTORY: 'public://images/profile/'
|
||||||
|
|
||||||
|
ids:
|
||||||
|
- page
|
||||||
|
|
||||||
|
process:
|
||||||
|
uid:
|
||||||
|
plugin: default_value
|
||||||
|
default_value: 1
|
||||||
|
|
||||||
|
pseudo_destination_filename:
|
||||||
|
# Skips a row if has_images property is set to FALSE.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: has_images
|
||||||
|
value: 'FALSE'
|
||||||
|
method: row
|
||||||
|
-
|
||||||
|
plugin: skip_on_empty
|
||||||
|
method: row
|
||||||
|
message: 'Cannot import image file with an empty url.'
|
||||||
|
-
|
||||||
|
plugin: callback
|
||||||
|
callable: basename
|
||||||
|
source: image_url
|
||||||
|
pseudo_destination_path:
|
||||||
|
-
|
||||||
|
plugin: concat
|
||||||
|
source:
|
||||||
|
- constants/DRUPAL_FILE_DIRECTORY
|
||||||
|
- '@pseudo_destination_filename'
|
||||||
|
uri:
|
||||||
|
-
|
||||||
|
plugin: skip_on_empty
|
||||||
|
method: process
|
||||||
|
source: image_url
|
||||||
|
-
|
||||||
|
plugin: file_copy
|
||||||
|
source:
|
||||||
|
- image_url
|
||||||
|
- '@pseudo_destination_path'
|
||||||
|
file_exists: rename
|
||||||
|
move: false
|
||||||
|
|
||||||
|
destination:
|
||||||
|
plugin: 'entity:file'
|
||||||
|
|
||||||
|
|
||||||
|
# make sure these migration execute before running current migration
|
||||||
|
migration_dependencies: null
|
||||||
|
|
||||||
|
# use forced module dependency so uninstall/reinstall works properly
|
||||||
|
dependencies:
|
||||||
|
enforced:
|
||||||
|
module:
|
||||||
|
- cdesai_migrate
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
# Migration configuration for creating media items.
|
||||||
|
id: cdesai_profile_pages_media_items
|
||||||
|
label: Import Profile Page Media
|
||||||
|
migration_group: CDESAI_MEDIA
|
||||||
|
|
||||||
|
source:
|
||||||
|
# The custom CSV source plugin will fetch the source path from configs.
|
||||||
|
# Upload source files at /admin/config/development/cdesai/migrate.
|
||||||
|
plugin: 'cdesai_migrate_csv'
|
||||||
|
source_config_key: cdesai_migrate_profile_pages_source
|
||||||
|
|
||||||
|
delimiter: ','
|
||||||
|
enclosure: '"'
|
||||||
|
header_offset: 0
|
||||||
|
|
||||||
|
ids:
|
||||||
|
- page
|
||||||
|
|
||||||
|
process:
|
||||||
|
pseudo_destination_filename:
|
||||||
|
# Skips a row if has_images property is set to FALSE.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: has_images
|
||||||
|
value: 'FALSE'
|
||||||
|
method: row
|
||||||
|
-
|
||||||
|
plugin: skip_on_empty
|
||||||
|
method: row
|
||||||
|
message: 'Cannot import image file with an empty url.'
|
||||||
|
-
|
||||||
|
plugin: callback
|
||||||
|
callable: basename
|
||||||
|
source: image_url
|
||||||
|
|
||||||
|
name: '@pseudo_destination_filename'
|
||||||
|
|
||||||
|
field_media_image/target_id:
|
||||||
|
plugin: migration_lookup
|
||||||
|
migration: cdesai_profile_pages_image_files
|
||||||
|
source: page
|
||||||
|
|
||||||
|
field_media_image/alt: title
|
||||||
|
|
||||||
|
thumbnail/target_id:
|
||||||
|
plugin: migration_lookup
|
||||||
|
migration: cdesai_profile_pages_image_files
|
||||||
|
source: page
|
||||||
|
|
||||||
|
thumbnail/alt: title
|
||||||
|
|
||||||
|
uid:
|
||||||
|
plugin: default_value
|
||||||
|
default_value: 1
|
||||||
|
|
||||||
|
langcode: en
|
||||||
|
|
||||||
|
destination:
|
||||||
|
plugin: 'entity:media'
|
||||||
|
default_bundle: image
|
||||||
|
|
||||||
|
# make sure these migration execute before running current migration
|
||||||
|
migration_dependencies:
|
||||||
|
required:
|
||||||
|
- cdesai_profile_pages_image_files
|
||||||
|
|
||||||
|
# use forced module dependency so uninstall/reinstall works properly
|
||||||
|
dependencies:
|
||||||
|
enforced:
|
||||||
|
module:
|
||||||
|
- cdesai_migrate
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
# Migration configuration for generating redirects from legacy url to Drupal nodes.
|
||||||
|
id: cdesai_migrate_page_redirects
|
||||||
|
label: 'Legacy Page Redirects'
|
||||||
|
migration_group: CDESAI
|
||||||
|
|
||||||
|
source:
|
||||||
|
# Upload source files at /admin/config/development/cdesai/migrate.
|
||||||
|
plugin: cdesai_paragraph_migrate_source
|
||||||
|
|
||||||
|
process:
|
||||||
|
language:
|
||||||
|
plugin: default_value
|
||||||
|
source: language
|
||||||
|
default_value: und
|
||||||
|
|
||||||
|
uid:
|
||||||
|
plugin: default_value
|
||||||
|
default_value: 1
|
||||||
|
|
||||||
|
status_code:
|
||||||
|
plugin: default_value
|
||||||
|
default_value: 301
|
||||||
|
|
||||||
|
redirect_source/path:
|
||||||
|
# Skips a row if skip_migration property is set to TRUE.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: skip_migration
|
||||||
|
value: 'TRUE'
|
||||||
|
method: row
|
||||||
|
# Skips a row if legacy_url property is EMPTY.
|
||||||
|
-
|
||||||
|
plugin: skip_on_value
|
||||||
|
equals: true
|
||||||
|
source: legacy_url
|
||||||
|
value: ''
|
||||||
|
method: row
|
||||||
|
-
|
||||||
|
plugin: substr
|
||||||
|
source: legacy_url
|
||||||
|
start: 1
|
||||||
|
|
||||||
|
redirect_redirect/title: ''
|
||||||
|
|
||||||
|
redirect_redirect/uri:
|
||||||
|
# Uses the custom process plugin to extract paragraph contents from a text file.
|
||||||
|
-
|
||||||
|
plugin: generate_redirect_uri
|
||||||
|
source: legacy_url
|
||||||
|
|
||||||
|
destination:
|
||||||
|
plugin: entity:redirect
|
||||||
|
|
||||||
|
# make sure these migration execute before running current migration
|
||||||
|
migration_dependencies:
|
||||||
|
required:
|
||||||
|
- cdesai_articles
|
||||||
|
- cdesai_basic_pages
|
||||||
|
|
||||||
|
# use forced module dependency so uninstall/reinstall works properly
|
||||||
|
dependencies:
|
||||||
|
enforced:
|
||||||
|
module:
|
||||||
|
- cdesai_migrate
|
||||||
Reference in New Issue
Block a user