@strapi/data-transfer 4.19.0 → 4.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1513,6 +1513,23 @@ const createLinkQuery = (strapi2, trx) => {
1513
1513
  yield link2;
1514
1514
  }
1515
1515
  }
1516
+ if (attribute.morphColumn) {
1517
+ const { typeColumn, idColumn } = attribute.morphColumn;
1518
+ const qb = connection.queryBuilder().select("id", typeColumn.name, idColumn.name).from(addSchema(metadata.tableName)).whereNotNull(typeColumn.name).whereNotNull(idColumn.name);
1519
+ if (trx) {
1520
+ qb.transacting(trx);
1521
+ }
1522
+ const entries = await qb;
1523
+ for (const entry of entries) {
1524
+ const ref = entry[idColumn.name];
1525
+ yield {
1526
+ kind,
1527
+ relation,
1528
+ left: { type: uid, ref: entry.id, field: fieldName },
1529
+ right: { type: entry[typeColumn.name], ref }
1530
+ };
1531
+ }
1532
+ }
1516
1533
  }
1517
1534
  async function* generateAll(uid) {
1518
1535
  const metadata = strapi2.db.metadata.get(uid);
@@ -1588,6 +1605,17 @@ const createLinkQuery = (strapi2, trx) => {
1588
1605
  });
1589
1606
  }
1590
1607
  }
1608
+ if ("morphColumn" in attribute && attribute.morphColumn) {
1609
+ const { morphColumn } = attribute;
1610
+ const qb = connection(addSchema(metadata.tableName)).where("id", left.ref).update({
1611
+ [morphColumn.idColumn.name]: right.ref,
1612
+ [morphColumn.typeColumn.name]: right.type
1613
+ });
1614
+ if (trx) {
1615
+ qb.transacting(trx);
1616
+ }
1617
+ await qb;
1618
+ }
1591
1619
  };
1592
1620
  return { generateAll, generateAllForAttribute, insert };
1593
1621
  };