User login

Date field date-only migration from Drupal 7 to Drupal 8

After we did the upgrade of a Drupal 7 site to Drupal 8, a date field which had been taking only the date portion, and no time portion, was now configured to take both the date and the time. Moreover, the migration wasn't working.

We changed the configuration from datetime to date

Here's the relevant part of the diff for config/default/field.storage.node.field_pub_date.yml

 field_name: field_pub_date
 entity_type: node
 type: datetime
 settings:
-  datetime_type: datetime
+  datetime_type: date
 module: datetime
 locked: false
 cardinality: 1

Note that changing this configuration requires a re-install of the site— storage settings can't be changed in an operating site.

The date was actually imported but, as shown by a "SELECT field_pub_date_value, entity_id FROM node__field_pub_date;" query, in the format "2016-10-10 00:00:00". That caused it to not display, and when editing, to show the field as blank. Saving the node after filling out the blanked field showed that it was saved as "2016-10-10" in normal operation.

In config/default/migrate_plus.migration.upgrade_d7_node_article.yml changing the line the Drupal upgrade had left us, "field_pub_date: field_pub_date" under the process directive, to the following instead, fixed the date migration:

process:
  field_pub_date:
    plugin: iterator
    source: field_pub_date
    process:
      value:
        plugin: substr
        source: value
        start: 0
        length: 10
Searched words: 
drupal 8 date migrate drupal 8 migrate datetime field not migrated drupal 7 to drupal 8 "date" migration The input value must be a string.

Comments

I had this same problem; I've

I had this same problem; I've filed an issue and uploaded a patch here: https://www.drupal.org/node/2894068

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.