fix: avoid n+1 query (#4085)

This commit is contained in:
Laurin Quast 2024-02-26 13:40:21 +01:00 committed by GitHub
parent 600433dfde
commit 1ecdd4861c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 11 deletions

View file

@ -290,7 +290,7 @@ export class SchemaVersionHelper {
beforeVersionCreatedAt: schemaVersion.createdAt,
});
return !!composableVersion;
return !composableVersion;
}
async getServiceSdlForPreviousVersionService(schemaVersion: SchemaVersion, serviceName: string) {

View file

@ -2635,16 +2635,18 @@ export async function createStorage(connection: string, maximumPoolSize: number)
conditionalBreakingChangeMetadata: input.conditionalBreakingChangeMetadata,
});
await Promise.all(
input.logIds.concat(log.id).map(async lid => {
await trx.query(sql`
INSERT INTO schema_version_to_log
(version_id, action_id)
VALUES
(${version.id}, ${lid})
`);
}),
);
await trx.query(sql`
INSERT INTO schema_version_to_log
(version_id, action_id)
SELECT * FROM
${sql.unnest(
input.logIds.concat(log.id).map(actionId =>
// Note: change.criticality.level is actually a computed value from meta
[version.id, actionId],
),
['uuid', 'uuid'],
)}
`);
await insertSchemaVersionChanges(trx, {
versionId: version.id,