Drupal 7 Date field with end date, to Drupal 8 Date Range field

Created on 3 December 2018, almost 6 years ago
Updated 5 April 2023, over 1 year ago

I'm just starting out with D8 and I'm trying to migrate a D7 datetime with an end date to a D8 daterange field, but the field migration `migrate_plus.migration.upgrade_d7_field.yml` always creates a datetime field rather than a daterange:

DESCRIBE node__field_display_dates;
+---------------------------+------------------+------+-----+---------+-------+
| Field                     | Type             | Null | Key | Default | Extra |
+---------------------------+------------------+------+-----+---------+-------+
| bundle                    | varchar(128)     | NO   | MUL |         |       |
| deleted                   | tinyint(4)       | NO   | PRI | 0       |       |
| entity_id                 | int(10) unsigned | NO   | PRI | NULL    |       |
| revision_id               | int(10) unsigned | NO   | MUL | NULL    |       |
| langcode                  | varchar(32)      | NO   | PRI |         |       |
| delta                     | int(10) unsigned | NO   | PRI | NULL    |       |
| field_display_dates_value | varchar(20)      | NO   | MUL | NULL    |       |
+---------------------------+------------------+------+-----+---------+-------+

I've been banging my head over this for days and can't seem to make any progress. The secret sauce required to migrate to create and populate a daterange field has eluded me.

I have mangaged to get the migration to work once with some judicious hacking, by editing the content type in the UI, and manually editing the `config` table to implemement the code in this comment 📌 FormatDate process plugin Fixed (Using the config import/export failed oh so spectacularly).

Any guidance would be much appreciated.

Installed core and contrib are latest release at time of writing.

Destination
Drupal 8.6.3

drush pml | grep -E "(date|migrat)" | grep Enabled
  Field types   Datetime (datetime)                   Enabled    8.6.3         
  Field types   Datetime Range (datetime_range)       Enabled    8.6.3         
  Migration     Migrate (migrate)                     Enabled    8.6.3         
  Migration     Migrate Drupal (migrate_drupal)       Enabled    8.6.3         
  Migration     Migrate Drupal UI (migrate_drupal_ui) Enabled    8.6.3         
  Migration     Migrate Plus (migrate_plus)           Enabled    8.x-4.0       
  Migration     Migrate Tools (migrate_tools)         Enabled    8.x-4.0       
  Migration     Drupal Upgrade (migrate_upgrade)      Enabled    8.x-3.0-rc5   

Source
Drupal 7.61

drush pml | grep -i date | grep Enabled
 Date/Time      Date (date)                   Module  Enabled   7.x-2.10

Source Table

DESCRIBE field_data_field_display_dates;
+----------------------------+------------------+------+-----+---------+-------+
| Field                      | Type             | Null | Key | Default | Extra |
+----------------------------+------------------+------+-----+---------+-------+
| entity_type                | varchar(128)     | NO   | PRI |         |       |
| bundle                     | varchar(128)     | NO   | MUL |         |       |
| deleted                    | tinyint(4)       | NO   | PRI | 0       |       |
| entity_id                  | int(10) unsigned | NO   | PRI | NULL    |       |
| revision_id                | int(10) unsigned | YES  | MUL | NULL    |       |
| language                   | varchar(32)      | NO   | PRI |         |       |
| delta                      | int(10) unsigned | NO   | PRI | NULL    |       |
| field_display_dates_value  | datetime         | YES  |     | NULL    |       |
| field_display_dates_value2 | datetime         | YES  |     | NULL    |       |
+----------------------------+------------------+------+-----+---------+-------+
🐛 Bug report
Status

Closed: duplicate

Version

9.1

Component
Migration 

Last updated about 21 hours ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024