Skip to content

Instantly share code, notes, and snippets.

@chx
Created March 5, 2018 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chx/329c33825ec08aa222535a7a6bddc3d8 to your computer and use it in GitHub Desktop.
Save chx/329c33825ec08aa222535a7a6bddc3d8 to your computer and use it in GitHub Desktop.
# Every migration that references a file by Drupal 7 fid should specify this
# migration as an optional dependency.
id: odl_file
label: Files
migration_tags:
- Drupal 7
source:
plugin: d7_file
scheme: public
constants:
# The tool configuring this migration must set source_base_path. It
# represents the fully qualified path relative to which URIs in the files
# table are specified, and must end with a /. See source_full_path
# configuration in this migration's process pipeline as an example.
source_base_path: '/var/odl-d7'
zero: 0
process:
filename: filename
source_full_path:
-
plugin: concat
delimiter: /
source:
- constants/source_base_path
- filepath
-
plugin: urlencode
uri:
plugin: file_copy
move: true
source:
- '@source_full_path'
- uri
filemime: filemime
# No need to migrate filesize, it is computed when file entities are saved.
# filesize: filesize
status: status
# Drupal 7 didn't keep track of the file's creation or update time -- all it
# had was the vague "timestamp" column. So we'll use it for both.
created: timestamp
changed: timestamp
uid: constants/zero
destination:
plugin: entity:file
id: odl_attendance
source:
plugin: odl_attendance
constants:
type: odl_order_item_type
gbp: GBP
process:
type: constants/type
order_id:
-
plugin: migration_lookup
migration: odl_order
source: order_id
-
plugin: odl_fake_order
unit_price/0/number: price
unit_price/0/currency_code: constants/gbp
# OrderItem::preSave recalculates the total.
purchased_entity:
-
plugin: migration_lookup
migration: odl_event
source: nid
no_stub: true
-
plugin: skip_on_empty
method: row
-
plugin: odl_find_variation
field_attended: has_attended
field_waitlisted:
plugin: static_map
source: field_name
map:
field_attending_paid: false
field_attending_part_paid: false
field_waiting_list_paid: true
field_waiting_list_part_paid: true
destination:
plugin: entity:commerce_order_item
migration_dependencies:
required:
- odl_order
- odl_event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment