Browse Source

fix(syncing-server): encapsulate delete queries into transactions

Karol Sójko 1 year ago
parent
commit
2ca649cf31

+ 2 - 0
packages/syncing-server/migrations/mysql/1690900526061-delete_privileges.ts

@@ -11,7 +11,9 @@ export class DeletePrivileges1690900526061 implements MigrationInterface {
     const batchCount = Math.ceil(itemsWithPrivilegesContentTypeCount / batchSize)
 
     for (let batchIndex = 0; batchIndex < batchCount; batchIndex++) {
+      await queryRunner.startTransaction()
       await queryRunner.manager.query(`DELETE FROM items WHERE content_type = "SN|Privileges" LIMIT ${batchSize}`)
+      await queryRunner.commitTransaction()
     }
   }
 

+ 2 - 0
packages/syncing-server/migrations/sqlite/1690901030484-delete_privileges.ts

@@ -11,7 +11,9 @@ export class DeletePrivileges1690901030484 implements MigrationInterface {
     const batchCount = Math.ceil(itemsWithPrivilegesContentTypeCount / batchSize)
 
     for (let batchIndex = 0; batchIndex < batchCount; batchIndex++) {
+      await queryRunner.startTransaction()
       await queryRunner.manager.query(`DELETE FROM items WHERE content_type = "SN|Privileges" LIMIT ${batchSize}`)
+      await queryRunner.commitTransaction()
     }
   }