Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
After migration with the build-in migration modules, the date-time fields in the view are empty. Also in edit-mode the field is empty. In the database the values are visible.
Comments
Comment #2
mikeryanThe date stored there in D8 is actually wrong - the format is 2016-10-25T16:43:21. Looks like we need a process plugin to translate.
See also #2566779: Migration D6 > D8 of CCK date fields.
Comment #4
kcolwell CreditAttribution: kcolwell commentedIf you need a quick fix for this problem until the bug is really fixed the code below will get things semi-working. It's not the right way to do this but it will convert the date to the correct format for drupal 8. My table name was node__field_eventstart and the column is field_eventstart_value. Change those in the code below to match your table and field. Backup your database first... then save this file as fix_date.php and run with the command line php fix_date.php.
Comment #5
tzsl CreditAttribution: tzsl as a volunteer commentedThanks for your quick fix. I have update all the datefields.
Comment #6
irinaz CreditAttribution: irinaz as a volunteer commented@mikeryan
Our team built process plugin to convert date (attache here, custom_migrate.zip). What is best way to package it so it can be tested and included in core?
Comment #7
mikeryanThis work is already in progress at #2820490: FormatDate process plugin and #2566779: Migration D6 > D8 of CCK date fields.
Comment #8
irinaz CreditAttribution: irinaz as a volunteer commentedThanks for pointing me to the new thread! I will do testing and report results. Can I ask here - is there thread for converting longtext-plaintext format for drupal7 to text-plain,long in drupal8?
thanks!
Comment #9
mikeryan@irinaz: I was a bit short in my previous reply, just threw that out there on my way out the door. For information on contributing to Drupal, the main resource is https://www.drupal.org/docs/develop. More specifically, for contributing patches to Drupal, see https://www.drupal.org/node/707484.
In terms of finding an existing issue, the issue queue is searchable - for example, https://www.drupal.org/project/issues/search/drupal?text=format&project_... searches for open migration system issues mentioning "format". In that list, #2842222: D7 Plain text fields incorrectly migrated to D8 as Text (formatted) may be what you're looking for.
Comment #10
irinaz CreditAttribution: irinaz as a volunteer commented@mikeryan - thank you VERY much, it is the issue. Our team with try to contribute what we can to have both issues moved forward.
Comment #11
vpa24 CreditAttribution: vpa24 commentedComment #12
cilefen CreditAttribution: cilefen as a volunteer commented@vpa24 I restored the original issue summary. The meaning of the edit you made is not clear.
Comment #13
Ralkeon CreditAttribution: Ralkeon as a volunteer and commentedSorry guys, but I don't understand why this was closed as duplicate refering to a d6 > d8 issue.
Reopening this cause I'm facing the issue on d7 > d8 hoping it helps someone.
I've two field date on two different content types. One of them is working, the other one is not... I figured out that the one is working was set (in the configuration file in the sync folder) on
datetime_type: datetime
and the other one wasdatetime_type: date
.I used the code suggested above to change the format to date only and it worked!
basically I've changed this part:
DATE_FORMAT( src.field_eventstart_value, '%Y-%m-%dT%H:%i:%S')
to this:
DATE_FORMAT( src.field_eventstart_value, '%Y-%m-%d')
Comment #14
vpa24 CreditAttribution: vpa24 as a volunteer commentedThis is my custom module can help fix date. You just go to admin/config/development/fix-date
https://github.com/vpa24/fix_date/
Comment #15
vpa24 CreditAttribution: vpa24 as a volunteer commentedThis is my custom module can help fix date. You just go to admin/config/development/fix-date
https://github.com/vpa24/fix_date/
Comment #16
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedComment #17
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedHere is a patch without a test. Once applied, recreate migrations and you should get the right to_format for fields that have a granularity of just the date.
Comment #18
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedOops. I marked it as not to be tested. Uploading again.
Comment #20
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedHere is an updated patch that should fix the multiple test warnings.
Comment #21
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedHere I have extended test coverage. This is the coverage report for the class that I modified before this patch:
And here is using this patch:
Comment #23
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedThis patch adds an adjustment to core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldLegacyTest.php so tests pass.
Comment #24
quietone CreditAttribution: quietone at Acro Commerce commentedON a very brief look, the change here looks similar to what is done in #3007102: Migrating to Date-only field does not drop time value. What is the difference?
Comment #25
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedYeah, it seems the same bug @quietone, just that I am testing the class differently.
Feel free to mark this one as a duplicate if you consider it fit.
Comment #26
quietone CreditAttribution: quietone as a volunteer commented@juampynr, thanks that helped. I don't see similar tests in the other issue so let move the tests here over to #3007102: Migrating to Date-only field does not drop time value. Once that is done this can be marked as a duplicate.
Comment #27
mikelutzI've merged the explicit unit tests from here into #3007102: Migrating to Date-only field does not drop time value and am closing this as a duplicate.
@juampynr is already credited on that issue, and I've transferred @vpa24's credit over there as well.