@strapi/data-transfer 4.19.1 → 4.20.1

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.mjs CHANGED
@@ -1480,6 +1480,23 @@ const createLinkQuery = (strapi2, trx) => {
1480
1480
  yield link2;
1481
1481
  }
1482
1482
  }
1483
+ if (attribute.morphColumn) {
1484
+ const { typeColumn, idColumn } = attribute.morphColumn;
1485
+ const qb = connection.queryBuilder().select("id", typeColumn.name, idColumn.name).from(addSchema(metadata.tableName)).whereNotNull(typeColumn.name).whereNotNull(idColumn.name);
1486
+ if (trx) {
1487
+ qb.transacting(trx);
1488
+ }
1489
+ const entries = await qb;
1490
+ for (const entry of entries) {
1491
+ const ref = entry[idColumn.name];
1492
+ yield {
1493
+ kind,
1494
+ relation,
1495
+ left: { type: uid, ref: entry.id, field: fieldName },
1496
+ right: { type: entry[typeColumn.name], ref }
1497
+ };
1498
+ }
1499
+ }
1483
1500
  }
1484
1501
  async function* generateAll(uid) {
1485
1502
  const metadata = strapi2.db.metadata.get(uid);
@@ -1555,6 +1572,17 @@ const createLinkQuery = (strapi2, trx) => {
1555
1572
  });
1556
1573
  }
1557
1574
  }
1575
+ if ("morphColumn" in attribute && attribute.morphColumn) {
1576
+ const { morphColumn } = attribute;
1577
+ const qb = connection(addSchema(metadata.tableName)).where("id", left.ref).update({
1578
+ [morphColumn.idColumn.name]: right.ref,
1579
+ [morphColumn.typeColumn.name]: right.type
1580
+ });
1581
+ if (trx) {
1582
+ qb.transacting(trx);
1583
+ }
1584
+ await qb;
1585
+ }
1558
1586
  };
1559
1587
  return { generateAll, generateAllForAttribute, insert };
1560
1588
  };