mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-28 06:46:24 +03:00
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:
parent
9a23f9b322
commit
339aee6dbb
@ -138,7 +138,7 @@ export class WorkspaceMigrationEnumService {
|
|||||||
`SELECT id, "${oldColumnName}" FROM "${schemaName}"."${tableName}"`,
|
`SELECT id, "${oldColumnName}" FROM "${schemaName}"."${tableName}"`,
|
||||||
);
|
);
|
||||||
|
|
||||||
values.map(async (value) => {
|
for (const value of values) {
|
||||||
let val = value[oldColumnName];
|
let val = value[oldColumnName];
|
||||||
|
|
||||||
if (/^\{.*\}$/.test(val)) {
|
if (/^\{.*\}$/.test(val)) {
|
||||||
@ -159,7 +159,7 @@ export class WorkspaceMigrationEnumService {
|
|||||||
SET "${columnDefinition.columnName}" = ${val}
|
SET "${columnDefinition.columnName}" = ${val}
|
||||||
WHERE id='${value.id}'
|
WHERE id='${value.id}'
|
||||||
`);
|
`);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async dropOldEnumType(
|
private async dropOldEnumType(
|
||||||
|
Loading…
Reference in New Issue
Block a user