diff --git a/packages/backend-core/src/users/db.ts b/packages/backend-core/src/users/db.ts index 326bed3cc5..01fa4899d1 100644 --- a/packages/backend-core/src/users/db.ts +++ b/packages/backend-core/src/users/db.ts @@ -2,7 +2,7 @@ import env from "../environment" import * as eventHelpers from "./events" import * as accountSdk from "../accounts" import * as cache from "../cache" -import { doInTenant, getGlobalDB, getIdentity, getTenantId } from "../context" +import { getGlobalDB, getIdentity, getTenantId } from "../context" import * as dbUtils from "../db" import { EmailUnavailableError, HTTPError } from "../errors" import * as platform from "../platform" diff --git a/packages/server/src/appMigrations/migrations/20231229122514_update_link_documents.ts b/packages/server/src/appMigrations/migrations/20231229122514_update_link_documents.ts index e1e1d4efc6..adaa0653c4 100644 --- a/packages/server/src/appMigrations/migrations/20231229122514_update_link_documents.ts +++ b/packages/server/src/appMigrations/migrations/20231229122514_update_link_documents.ts @@ -1,5 +1,6 @@ -import { SEPARATOR, context } from "@budibase/backend-core" +import { context } from "@budibase/backend-core" import { allLinkDocs } from "../../db/utils" +import LinkDocumentImpl from "../../db/linkedRows/LinkDocument" const migration = async () => { const linkDocs = await allLinkDocs() @@ -11,9 +12,14 @@ const migration = async () => { continue } - linkDoc.tableId = [linkDoc.doc1.tableId, linkDoc.doc2.tableId] - .sort() - .join(SEPARATOR) + linkDoc.tableId = new LinkDocumentImpl( + linkDoc.doc1.tableId, + linkDoc.doc1.fieldName, + linkDoc.doc1.rowId, + linkDoc.doc2.tableId, + linkDoc.doc2.fieldName, + linkDoc.doc2.rowId + ).tableId docsToUpdate.push(linkDoc) } diff --git a/packages/server/src/db/linkedRows/LinkDocument.ts b/packages/server/src/db/linkedRows/LinkDocument.ts index 234f43cb48..05097ed84f 100644 --- a/packages/server/src/db/linkedRows/LinkDocument.ts +++ b/packages/server/src/db/linkedRows/LinkDocument.ts @@ -1,6 +1,6 @@ import { generateLinkID } from "../utils" import { FieldTypes } from "../../constants" -import { LinkDocument } from "@budibase/types" +import { LinkDocument, SEPARATOR } from "@budibase/types" /** * Creates a new link document structure which can be put to the database. It is important to @@ -17,6 +17,7 @@ import { LinkDocument } from "@budibase/types" class LinkDocumentImpl implements LinkDocument { _id: string type: string + tableId: string doc1: { rowId: string fieldName: string @@ -54,7 +55,11 @@ class LinkDocumentImpl implements LinkDocument { fieldName: fieldName2, rowId: rowId2, } + this.tableId = [this.doc1.tableId, this.doc2.tableId].sort().join(SEPARATOR) } + _rev?: string | undefined + createdAt?: string | number | undefined + updatedAt?: string | undefined } export default LinkDocumentImpl diff --git a/packages/server/src/db/linkedRows/index.ts b/packages/server/src/db/linkedRows/index.ts index 7af3f9392f..934b9d4a75 100644 --- a/packages/server/src/db/linkedRows/index.ts +++ b/packages/server/src/db/linkedRows/index.ts @@ -18,7 +18,6 @@ import { Row, LinkDocumentValue, FieldType, - LinkDocument, ContextUser, } from "@budibase/types" import sdk from "../../sdk"