From 8bd62ecede9bd582c12facdef46e7d532dbe7ebb Mon Sep 17 00:00:00 2001
From: Andrey Sobolev <haiodo@users.noreply.github.com>
Date: Mon, 21 Oct 2024 12:16:40 +0700
Subject: [PATCH] UBERF-8504: Fix DocSyncInfo in transactions (#6998)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
---
 packages/core/src/operations.ts               | 5 +++--
 services/github/model-github/src/migration.ts | 8 +++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/packages/core/src/operations.ts b/packages/core/src/operations.ts
index 9db10bdae0..7f77335e75 100644
--- a/packages/core/src/operations.ts
+++ b/packages/core/src/operations.ts
@@ -444,7 +444,8 @@ export class ApplyOperations extends TxOperations {
   constructor (
     readonly ops: TxOperations,
     readonly scope?: string,
-    readonly measureName?: string
+    readonly measureName?: string,
+    isDerived?: boolean
   ) {
     const txClient: Client = {
       getHierarchy: () => ops.client.getHierarchy(),
@@ -460,7 +461,7 @@ export class ApplyOperations extends TxOperations {
         return {}
       }
     }
-    super(txClient, ops.user)
+    super(txClient, ops.user, isDerived ?? false)
   }
 
   match<T extends Doc>(_class: Ref<Class<T>>, query: DocumentQuery<T>): ApplyOperations {
diff --git a/services/github/model-github/src/migration.ts b/services/github/model-github/src/migration.ts
index 540bcf1580..63f888ab6a 100644
--- a/services/github/model-github/src/migration.ts
+++ b/services/github/model-github/src/migration.ts
@@ -2,7 +2,7 @@
 // Copyright © 2023 Hardcore Engineering Inc.
 //
 
-import core, { toIdMap, type AnyAttribute, type Ref, type Status } from '@hcengineering/core'
+import core, { DOMAIN_TX, toIdMap, type AnyAttribute, type Ref, type Status } from '@hcengineering/core'
 import {
   tryMigrate,
   tryUpgrade,
@@ -326,6 +326,12 @@ export const githubOperationPreTime: MigrateOperation = {
       {
         state: 'migrate-missing-states',
         func: migrateMissingStates
+      },
+      {
+        state: 'remove-doc-sync-info-txes',
+        func: async (client) => {
+          await client.deleteMany(DOMAIN_TX, { objectClass: github.class.DocSyncInfo })
+        }
       }
     ])
   },