Create link docs to new docs
This commit is contained in:
parent
4a1b99a9dc
commit
e265cc635c
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -18,7 +18,6 @@ import {
|
|||
Row,
|
||||
LinkDocumentValue,
|
||||
FieldType,
|
||||
LinkDocument,
|
||||
ContextUser,
|
||||
} from "@budibase/types"
|
||||
import sdk from "../../sdk"
|
||||
|
|
Loading…
Reference in New Issue