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 eventHelpers from "./events"
|
||||||
import * as accountSdk from "../accounts"
|
import * as accountSdk from "../accounts"
|
||||||
import * as cache from "../cache"
|
import * as cache from "../cache"
|
||||||
import { doInTenant, getGlobalDB, getIdentity, getTenantId } from "../context"
|
import { getGlobalDB, getIdentity, getTenantId } from "../context"
|
||||||
import * as dbUtils from "../db"
|
import * as dbUtils from "../db"
|
||||||
import { EmailUnavailableError, HTTPError } from "../errors"
|
import { EmailUnavailableError, HTTPError } from "../errors"
|
||||||
import * as platform from "../platform"
|
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 { allLinkDocs } from "../../db/utils"
|
||||||
|
import LinkDocumentImpl from "../../db/linkedRows/LinkDocument"
|
||||||
|
|
||||||
const migration = async () => {
|
const migration = async () => {
|
||||||
const linkDocs = await allLinkDocs()
|
const linkDocs = await allLinkDocs()
|
||||||
|
@ -11,9 +12,14 @@ const migration = async () => {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
linkDoc.tableId = [linkDoc.doc1.tableId, linkDoc.doc2.tableId]
|
linkDoc.tableId = new LinkDocumentImpl(
|
||||||
.sort()
|
linkDoc.doc1.tableId,
|
||||||
.join(SEPARATOR)
|
linkDoc.doc1.fieldName,
|
||||||
|
linkDoc.doc1.rowId,
|
||||||
|
linkDoc.doc2.tableId,
|
||||||
|
linkDoc.doc2.fieldName,
|
||||||
|
linkDoc.doc2.rowId
|
||||||
|
).tableId
|
||||||
docsToUpdate.push(linkDoc)
|
docsToUpdate.push(linkDoc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { generateLinkID } from "../utils"
|
import { generateLinkID } from "../utils"
|
||||||
import { FieldTypes } from "../../constants"
|
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
|
* 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 {
|
class LinkDocumentImpl implements LinkDocument {
|
||||||
_id: string
|
_id: string
|
||||||
type: string
|
type: string
|
||||||
|
tableId: string
|
||||||
doc1: {
|
doc1: {
|
||||||
rowId: string
|
rowId: string
|
||||||
fieldName: string
|
fieldName: string
|
||||||
|
@ -54,7 +55,11 @@ class LinkDocumentImpl implements LinkDocument {
|
||||||
fieldName: fieldName2,
|
fieldName: fieldName2,
|
||||||
rowId: rowId2,
|
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
|
export default LinkDocumentImpl
|
||||||
|
|
|
@ -18,7 +18,6 @@ import {
|
||||||
Row,
|
Row,
|
||||||
LinkDocumentValue,
|
LinkDocumentValue,
|
||||||
FieldType,
|
FieldType,
|
||||||
LinkDocument,
|
|
||||||
ContextUser,
|
ContextUser,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import sdk from "../../sdk"
|
import sdk from "../../sdk"
|
||||||
|
|
Loading…
Reference in New Issue