fix: use existing transaction to batch insert (#21404)

This commit is contained in:
Ben Irvin 2024-09-24 10:00:14 +02:00 committed by GitHub
parent d2d15ef227
commit 9cb35c0a30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -86,8 +86,6 @@ const sync = async (
);
await strapi.db.transaction(async ({ trx }) => {
const con = strapi.db.getConnection();
// Iterate old relations that are deleted and insert the new ones
for (const { joinTable, relations } of oldRelations) {
// Update old ids with the new ones
@ -98,7 +96,7 @@ const sync = async (
});
// Insert those relations into the join table
await con.batchInsert(joinTable.name, newRelations).transacting(trx);
await trx.batchInsert(joinTable.name, newRelations, 1000);
}
});
};