Problem/Motivation

Migrating from D8 FC 1.x to D8 paragraphs. All the data appears to be migrated correctly. The only one not imported correctly is the field_collection_to_paragraph_parent_node migration.

field_collection_to_paragraph_parent_node                       Idle    121    121

Migration completed without issue or error. But the respective paragraphs entity reference revision fields are all empty.

Comments

ckng created an issue. See original summary.

damienmckenna’s picture

Category: Support request » Bug report
Priority: Normal » Critical

I can confirm this bug.

damienmckenna’s picture

After running the migraiton the parent_id, parent_type and parent_field_name values in the paragraphs_item_field_data table are blank.

damienmckenna’s picture

The new fields on the parent entity (node__FIELDNAME_paragraph) are also blank.

ckng’s picture

Yes, correct, same observation. Going through the codes.

damienmckenna’s picture

I noticed that when you first install the module and run migrate:status the field_collection_to_paragraph_parent_node migration shows zero records to import, but then when it runs it finds some records, though not all of them.

So there are two problems here: the query is wrong, and the data doesn't get migrated.

damienmckenna’s picture

query() generates a query that looks like this:

SELECT "n"."nid" AS "nid", "n"."vid" AS "vid"
FROM
{node} "n"
LEFT OUTER JOIN {node__field_FIELDNAME} "node__field_FIELDNAME" ON node__field_FIELDNAME.entity_id = n.nid
WHERE ("node__field_FIELDNAME"."field_FIELDNAME_value" IS NOT NULL) AND ("n"."type" IN (:db_condition_placeholder_0))
GROUP BY n.nid, n.vid

Shouldn't it query the source data instead of the destination data?

damienmckenna’s picture

Never mind, I forgot that the source is D8, so that part of the query is correct X-)

The query gets a list of unique node IDs that have the field records, so while there might be e.g. 200 records in the table there might only be 50 unique nodes as many of them have multiple values.

damienmckenna’s picture

When the import has not been ran yet $bundles does not have any values, so query() fails early. And that's because $mappings is empty. And $mappings is empty because migrate_map_field_collection_to_paragraph_parent_field_instance hasn't ran yet.

  • DamienMcKenna committed 02a4d4a on 2.x
    Issue #3224009 by DamienMcKenna: Added a docs note about migrate:status...
damienmckenna’s picture

When the migration gets to FieldCollectionParentNode::prepareRow() it has the node ID and revision ID but it doesn't have the paragraphs data, so it can't update the records. Instead it loops over the values from the node and just re-assigns them, which does nothing. It has FieldCollectionParentNode::$fields but that's hardcoded with most of the columns from node_field_data, but then it doesn't use it.

damienmckenna’s picture

I think the parent migrations should load all of the records from the original field and then manually save them in the new paragraphs field after reconfiguring the columns. Specifically, the source table has FIELDNAME_value and FIELDNAME_revision_id, while the destination has FIELDNAME_target_id and FIELDNAME_target_revision.

damienmckenna’s picture

I was going about this wrong - the source plugin isn't supposed to prep the data for the destination, FieldCollectionItemParentSourceMigration is supposed to add extra fields to the process section of the migration to map the data. But for some reason it doesn't seem to be executed.

mikeybycode: Did this actually work for you?

damienmckenna’s picture

It was suggested to update to the latest dev snapshot of Paragraphs, because of #2911244, but this didn't solve the problem for me.

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new685 bytes

I worked out the fix!

  • DamienMcKenna committed 315bf02 on 2.x
    Issue #3224009 by DamienMcKenna, ckng: Attach the paragraphs to the...
damienmckenna’s picture

Status: Needs review » Fixed

This fixes the problem in my local testing. Committed.

ckng’s picture

Tested, working for me too.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.