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.
Has anybody had success in migrating date fields from D6 to D8?
("date" fields provided by the Date module, used as CCK fields on nodes, stored as varchar(20) in D6).
Any help or scripts would be great.
Comment | File | Size | Author |
---|---|---|---|
#78 | 2566779-77.patch | 18.68 KB | jofitz |
#73 | interdiff_69-73.txt | 2.1 KB | heddn |
#73 | 2566779-73.patch | 18.63 KB | heddn |
Comments
Comment #2
quietone CreditAttribution: quietone as a volunteer commentedComment #3
13jupiters CreditAttribution: 13jupiters commentedA couple of notes in pursuit of solution. (I'm just coming to D8 so writing a migration plugin myself is at the moment beyond me.)
To recap, date fields are not migrating. However, some aspects of a date field DO migrate; specifically, in the D8 Config table, the (serialized) data for a migrated node-type does include proper information for date fields.
For example: if your D6 site includes a node type "Projects" with a CCK date field "content_field_deadline", the D8 site after migration will include a node type "Projects", but there will be no "field_deadline". However, the CONFIG table entry core.entity_view_display.node.projects.default will include some info on the missing date field:
field_deadline:
label: inline
weight: 13
type: datetime_default
settings:
format_type: fallback
timezone_override: ''
third_party_settings: { }
In other words, some aspects of the cck > D8 migration process are working for date fields, even though the actual fields don't migrate.
Comment #4
benjy CreditAttribution: benjy at PreviousNext commentedCan you dump the data from content_node_field and content_node_field_instance for the relevant fields? We do have tests for date fields so i'm guessing it must be something specific to your field configuration.
Also, how are you migrating, with migrate_upgrade? Are there any errors in the logs after migrating?
Comment #5
13jupiters CreditAttribution: 13jupiters commentedThanks for looking in on this! And to ask one question: so date fields have been known to migrate properly from D6 to D8?
I used migrate_upgrade (via drush, and via UI). Interestingly, there are no errors relating to the date fields. Expected errors relating to Node/User Reference fields and other problems which I anticipated.
Note that right now I'm just trying to find out whether date migrations work in general - i.e., whether I should be troubleshooting my migration, waiting for or helping with a plugin, or devising an ugly workaround.
In the Drupal 6 content_node_field table:
Drupal 6 content_node_field_instance:
And in Drupal 8 Config table, within core.entity_view_display.node.request.default:
A couple of notes:
- this iteration has the D6 date field as part of a field group; but other migration attempts with field group removed had same result.
Comment #6
13jupiters CreditAttribution: 13jupiters commentedAdditional note, possibly relevant:
Within the Config table, core.entity_view_display.node.request.default did NOT include date fields in the dependencies->config array.
Comment #7
Sutharsan CreditAttribution: Sutharsan commentedMy D6 site uses Datestamp type date fields. The content is migrated but in the wrong format. The node__field_date.field_date_value contains a unix timestamp: '1458086400'. The D6 source table also uses unix timestamp. When I create a D8 node the data is stored as '2016-03-14T22:52:20'.
Comment #8
mlbrgl CreditAttribution: mlbrgl as a volunteer commentedI tried exporting from a clean 6.38 to a clean 8.0.5 with the same results: no date fields were migrated.
D6
- modules installed: cck, date
- 3 fields created on the page content type: field_date_test, field_datetime_test and field_timestamp_test. Default settings for all three.
- 1 page created with the same value in all three fields: 04/02/2016 - 13:49
D8
- modules installed: migrate, migrate_upgrade, migrate_drupal, migrate_plus, migrate_tools
Migrations were run using drush 8.0.5.
I have attached dumps of the relevant D6 tables. Let me know if I can run some more tests to help debug that issue.
Comment #10
Shawn DeArmond CreditAttribution: Shawn DeArmond as a volunteer commentedIt appears that no migrate processes, templates, tests, etc. were created to migrate Date fields to D8.
At least not in Core nor in the Date module, though a separate issue was created in the date module issue queue here:
#2655308: Convert datestamp fields D6 to D8
If this is going to be solved in Core, then the other should be marked as a duplicate.
Comment #11
Shawn DeArmond CreditAttribution: Shawn DeArmond as a volunteer commentedWhile we're at it, let's make this a "Feature request".
Comment #12
Shawn DeArmond CreditAttribution: Shawn DeArmond as a volunteer commentedOkay, so my bad. There is definitely migrate code in core to support date migrations. Unfortunately, it doesn't appear to be working properly. At least not for the above user, nor for me. So I'm changing this to a "Bug report".
In D6, I have a date field with these global_settings:
a:7:{s:11:"granularity";a:2:{s:4:"year";s:4:"year";s:5:"month";s:5:"month";}s:11:"timezone_db";s:0:"";s:11:"tz_handling";s:4:"none";s:6:"todate";s:0:"";s:6:"repeat";i:0;s:16:"repeat_collapsed";s:0:"";s:14:"default_format";s:6:"medium";}
The field instance uses date_text widget with these widget_settings:
a:10:{s:13:"default_value";s:3:"now";s:18:"default_value_code";s:0:"";s:14:"default_value2";s:4:"same";s:19:"default_value_code2";s:0:"";s:12:"input_format";s:11:"Y-m-d H:i:s";s:19:"input_format_custom";s:3:"F Y";s:9:"increment";i:1;s:10:"text_parts";a:0:{}s:10:"year_range";s:5:"-3:+3";s:14:"label_position";s:4:"none";}
The field is not created during the migration.
Comment #13
Shawn DeArmond CreditAttribution: Shawn DeArmond as a volunteer commentedI have added migrate plugins for the datetime module It DEFINITELY needs work, because it still doesn't work, but I want to put my work out there and get some help.
Basically, the field type isn't mapping properly, and I don't know why. When it gets to CckFieldPluginBase.php line 75, in getFieldType(), it can't find the mapping to "date time", so it just thinks the field type is "date".
Comment #14
Shawn DeArmond CreditAttribution: Shawn DeArmond as a volunteer commentedLinking issue: #2631736-51: Cckfield Plugins must distinguish core versions
Also, I was able to import the date fields by adding the following to CckFieldPluginBase.php line 75:
Comment #15
quietone CreditAttribution: quietone as a volunteer commentedThe data in given in #5 has a widget of 'date_popup' and the one in #12 has a widget of 'date_text'. I don't see a migration path for them. I modified the d6 dump such that these widgets are being used by two of the existing date fields on the story content type and entered data for all the date fields. Tests have been added to MigrateFieldTest and MIgrateNodeTest.
Unfortunately, there is still a failure in MigrateNodeTest. The date data for all three fields is migrated to D8 but isn't retrieved when loading the node.
Comment #18
hussainwebLet's start with a reroll first.
Comment #20
hussainwebFixed the failure.
Comment #21
phenaproximaI was initially scared of reviewing this patch until I realized that 99% of it is changes to the D6 database fixture. Looks great! Thank you all.
Comment #23
phenaproximaComment #24
hussainwebRerolled. The conflicts were with timestamps in drupal6.php, so hopefully, tests pass.
Comment #25
phenaproximaTaking a second look at the patch, I'm wondering why new assertions haven't been added to the tests for the migrations changed in this patch...
Comment #26
keithm CreditAttribution: keithm commentedRerolled #24 for 8.2.x.
Comment #27
keithm CreditAttribution: keithm commentedNoting there is a conflict between date_migrate-2566779-24.patch and 2447727-182.patch. date_migrate-2566779-24.patch will not apply after 2447727-182.patch due to merge conflicts in core/modules/migrate_drupal/tests/fixtures/drupal6.php and core/modules/field/migration_templates/d6_field_instance_widget_settings.yml.
The test fixture looks straightforward to fix (see drupal6.php_.rej_.txt) but the changes to d6_field_instance_widget_settings.yml look more significant (d6_field_instance_widget_settings.yml.rej_.txt), since 2447727-182.patch changes the 'options/type' to no longer be a static_map.
Comment #28
phenaproximaComment #29
phenaproximaA couple of small things, then I think this is probably RTBC.
Let's use assertSame(), and we don't need to translate the assertion message.
Why did this get removed?
There needs to be a space after the second argument for each of these calls.
Comment #30
quietone CreditAttribution: quietone as a volunteer commentedFails to apply.
Comment #31
quietone CreditAttribution: quietone as a volunteer commentedThe reroll.
Comment #32
quietone CreditAttribution: quietone as a volunteer commentedBack to NW for the issues in #29.
Comment #33
kekkisRerolled again against 8.2.x after new commits there on Oct 21. As you can see in the interdiff, only line offsets have changed.
Also, I'm bold enought to unassign from @phenaproxima as it seems there is need for more contribution before a new round of review.
Comment #34
quietone CreditAttribution: quietone as a volunteer commentedAddressing the items in #29.
1 and 3. Fixed
2. i18n_lock_node_article exists, and is the same value, before and after the patch is applied. I can't explain what git diff is doing. However, it does look like the dump has unnecessary changes and needs to be trimmed down to just what is needed. That is something I can't do now, but maybe in a few days.
Comment #35
phenaproximaAssigning to myself for review.
Comment #36
heddnCan we get a no test patch that doesn't have the facets in it? It might make it easier for reviewing.
Comment #37
mikeryanI'll try to review this in the next week.
Comment #38
mikeryanI created date, datestamp, and datetime fields on a D6 site and performed a migration. All three fields were created on the node, but only the date field renders properly - as pointed out in #7 above, the actual values are copied as-is rather than converted to the "2014-03-14T07:03:00" form as used in D8.
Well, this does match the actual behavior - unfortunately, it's not the behavior we actually want:P.
Comment #39
heddnOn that side note then, does #2820490: FormatDate process plugin need to move to the core issue queue?
Comment #40
mikeryan@heddn: Yes! That plugin is generally useful enough to consider for core anyway, and it would address the problem here.
Postponing on the FormatDate plugin.
Comment #42
drupalok CreditAttribution: drupalok commentedsorry to bother... but what exactly do i have to do now to be able to migrate D6 to D8 date fields?
i wonder if there are any sites out there NOT using datefields in D6?
how come this has not been handled by core?
Comment #43
phenaproximaBecause there are many, many, many Migrate-related issues that need doing, and too few of us who are willing and/or able to do them. This is why core development moves very slowly. If you want to unblock this issue, working on #2820490: FormatDate process plugin would be a great way to do that.
Comment #44
mikeryanThis is a blocker to considering the Drupal-to-Drupal migration path stable.
Comment #45
osopolarDrupal 8 now has two datetime types: datetime and date. In patch #34 datetime is hardcoded (in FieldSettings.php getSettings():
'datetime' => array('datetime_type' => 'datetime'),
). What can I do if I want to use date only? In Drupal 6 the field settings where set by granularity to year + month + day. How would the solution look like, I I want to set "date only" only for one field (field_date_only) and use datetime all the others ... with less coding possible.Comment #46
heddnUse the process plugin from the related issue
Comment #47
osopolar@heddn: You mean #2820490: FormatDate process plugin? I am using that one too, its for the value formatting, but don't help for the field settings itself.
My problem is related to core/modules/field/src/Plugin/migrate/process/d6/FieldSettings.php: I don't can't see how to to overwrite datetime_type somewhere to set it to date (for date only).
Comment #48
quietone CreditAttribution: quietone as a volunteer commented#2820490: FormatDate process plugin is in. So no longer postponed.
Probably needs a reroll too.
Comment #49
quietone CreditAttribution: quietone as a volunteer commentedThe reroll.
Comment #50
quietone CreditAttribution: quietone as a volunteer commentedCorrected the tests that mikeryan pointed out in #38 were wrong. Added a cck date plugin. The value passed to FormatDate process plugin is array of value and delta and since FormatData expects a string the tests will fail. How do we deal with delta?
So more work to do. I'm on holiday for this long weekend, maybe someone can move this along?
Comment #52
quietone CreditAttribution: quietone as a volunteer commentedFixed DateField::processCckFieldValues().
Changed the type map so that datestamp is mapped to timestamp.
Updated the text in MigrateNodeTest
Comment #53
quietone CreditAttribution: quietone as a volunteer commentedSetting to NR helps...
Comment #55
quietone CreditAttribution: quietone as a volunteer commentedAdded date related tests in MigrateFieldTest. Fixed the failing test by adding the to_format for the datestamp type. And, if the field formatter does not exist an invalid from_format will be passed to FormatDate, which will throw an exception.
Comment #56
heddnShould we be extending from CCK or the new Field plugin?
Do we need to implement this? Perhaps no.
This is about what I would expect. Good.
Comment #57
heddnMoving back to NW for #56.
Comment #58
quietone CreditAttribution: quietone as a volunteer commented@heddn, thanks for the prompt review.
1. The Cck rename patch has not yet been ported to 8.3.x and this is issue is against 8.3.x
2. DateField extends CckFieldPluginBase which is abstract class implementing MigrateCckFieldInterface. getFieldFormatterMap is defined in MigrateCckFieldInterface but not in CckFieldPluginBase,
3. Sweet!
Comment #59
quietone CreditAttribution: quietone as a volunteer commentedActually, this needs work to clean up the fixture.
Comment #60
quietone CreditAttribution: quietone as a volunteer commentedRemoved unnecessary changes to the d6 test fixture. That is,kept only changes to the date fields.
Comment #61
phenaproximaLet's port this to 8.4.x so that we can use the Field plugin annotation and base class, rather than Cckfield. Then we can backport to 8.3.x if needed.
Comment #62
quietone CreditAttribution: quietone as a volunteer commentedOK, here it is. The interdiff is pretty useless/odd, it shows changes for things that were not changed.
Comment #63
phenaproximaI don't know how I feel about purposefully setting a value which will throw a MigrateException in another plugin. It seems like unnecessary tight coupling to me. That said, I'm not sure what else we could do. If we stick with this approach, we'll probably need to explicitly test this code path.
It doesn't make a whole lot of difference, but I think we should add instanceof checks immediately after these lines, like so:
That way, we can avoid fatals if the field doesn't exist.
We should be using short array syntax here ([]). I'd also like see some assertInstanceOf() checks added to avoid fatals if the field storages were not migrated properly.
Comment #64
quietone CreditAttribution: quietone as a volunteer commentedItems 2and 3 fixed.
As for the first one, I wasn't fond of that default value either. Considering that the DateField process is only executed when the type matches it shouldn't even be possible to get there if the type is not one of date, datestamp or datetime. Still, I'd prefer a default value. How about just using any of the three options, say 'date'?
Comment #65
phenaproximaIf it's not possible to get to that switch-case unless the incoming type is not one of date, datestamp, or datetime, let's throw either a MigrateException or InvalidArgumentException directly in the default case, rather than expect the FormatDate plugin to do it for us.
Also, small nitpick, but:
Extra blank line.
Comment #66
phenaproximaForgot to mention -- since the committers will likely kick it back without this, let's also add test coverage to ensure that an exception is, in fact, thrown if the incoming field type is invalid.
Comment #67
quietone CreditAttribution: quietone as a volunteer commentedOK, now throwing a MigrateException and test added.
Comment #69
quietone CreditAttribution: quietone as a volunteer commentedTest was in wrong directory.
Comment #70
phenaproximaLooks great! Let it roll.
Comment #71
Gábor HojtsyNitpick: If this is in reference to a method on a class, they should be separated by :: and not a newline :)
Is this really the field name or the date type name? If its the date type name, then is the error message helpful identifying which field has the problem? If we also know the field name, should we print the field name AND the date type name, so its easier to figure out where it comes from? Otherwise we are holding back useful information that could be really beneficial in debugging this error.
Comment #72
heddnWorking on this.
Comment #73
heddnComment #74
tomogden CreditAttribution: tomogden commented#71.1 Is fixed.
#71.2 Field name and data type are now labeled and specified.
Comment #75
Gábor HojtsyComment #76
heddnTagging novice for the re-roll.
Comment #77
jofitz CreditAttribution: jofitz at ComputerMinds commentedComment #78
jofitz CreditAttribution: jofitz at ComputerMinds commentedRe-rolled
Comment #79
phenaproximaYay, it passed! Back to RTBC.
Comment #80
Gábor HojtsyLet's get this tested on 8.3.x as well due to our recent problem with backports of migrate stuff. Does this require anything not yet backported to 8.3.x?
Comment #81
phenaproxima@Gabor Hojtsy: Yes, it requires #2683435: CCK does not exist in Drupal 7, rename Migrate's cckfield plugins to field plugins to be backported to 8.3.x.
Comment #82
jofitz CreditAttribution: jofitz at ComputerMinds commentedPostponing on #2683435: CCK does not exist in Drupal 7, rename Migrate's cckfield plugins to field plugins.
Comment #83
jofitz CreditAttribution: jofitz at ComputerMinds commentedNo longer blocked. Retesting against 8.3.x. Setting back to RTBC in expectation.
Comment #85
catchCommitted/pushed to 8.4.x and cherry-picked to 8.3.x, thanks!
Comment #88
heddnTagging for mention in 8.4.0 release notes.