mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
fix: pos seeder
This commit is contained in:
@@ -229,7 +229,18 @@ export class FreightPositionsSeeder {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await positionPermissionRepository.insert(rowsToInsert);
|
// orIgnore, not a bare insert: the read above and this write are not
|
||||||
|
// atomic across processes — two API replicas booting together (or a
|
||||||
|
// restart racing a running boot) both see the grant missing and both
|
||||||
|
// insert it, and the loser died on UQ_87ee8f7eef7366389a02ff69f04 with
|
||||||
|
// the whole seed transaction. ON CONFLICT DO NOTHING makes the grant
|
||||||
|
// idempotent no matter who else is inserting it.
|
||||||
|
await positionPermissionRepository
|
||||||
|
.createQueryBuilder()
|
||||||
|
.insert()
|
||||||
|
.values(rowsToInsert)
|
||||||
|
.orIgnore()
|
||||||
|
.execute();
|
||||||
|
|
||||||
this.logger.log(
|
this.logger.log(
|
||||||
`Granted ${rowsToInsert.length} permissions to position '${seed.key}'`,
|
`Granted ${rowsToInsert.length} permissions to position '${seed.key}'`,
|
||||||
|
|||||||
Reference in New Issue
Block a user