Run queries within queryRunner transaction sequentially (#5668)

Within a queryRunner transaction, it is important that migrations are
run subsequently and not concurrently: otherwise if an error is thrown
by one of the query, it will abort the transaction; any subsequent query
running on the same queryRunner will cause the error _current
transaction is aborted, commands ignored until end of transaction
block_.

Using an async function in a map as below does not guarantee that each
query terminates before iterating over the next one, which can be an
issue as described above, and which seems to cause [this
sentry](https://twenty-v7.sentry.io/issues/5258406553/?environment=prod&project=4507072499810304&query=is%3Aunresolved+issue.priority%3A%5Bhigh%2C+medium%5D&referrer=issue-stream&statsPeriod=7d&stream_index=4).
This commit is contained in:
Marie 2024-05-30 10:45:46 +02:00 committed by GitHub
parent 9a23f9b322
commit 339aee6dbb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -138,7 +138,7 @@ export class WorkspaceMigrationEnumService {
`SELECT id, "${oldColumnName}" FROM "${schemaName}"."${tableName}"`,
);
values.map(async (value) => {
for (const value of values) {
let val = value[oldColumnName];
if (/^\{.*\}$/.test(val)) {
@ -159,7 +159,7 @@ export class WorkspaceMigrationEnumService {
SET "${columnDefinition.columnName}" = ${val}
WHERE id='${value.id}'
`);
});
}
}
private async dropOldEnumType(