Merge branch 'master' into budi-7105-builder-option-for-read-only-form-fields
This commit is contained in:
commit
662e33cd66
|
@ -169,7 +169,7 @@ jobs:
|
||||||
- uses: peter-evans/repository-dispatch@v2
|
- uses: peter-evans/repository-dispatch@v2
|
||||||
with:
|
with:
|
||||||
repository: budibase/budibase-deploys
|
repository: budibase/budibase-deploys
|
||||||
event: budicloud-qa-deploy
|
event-type: budicloud-qa-deploy
|
||||||
github_pat: ${{ secrets.GH_ACCESS_TOKEN }}
|
github_pat: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||||
client-payload: |-
|
client-payload: |-
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "2.12.6",
|
"version": "2.12.7",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
|
|
|
@ -30,15 +30,15 @@
|
||||||
part2: PrettyRelationshipDefinitions.MANY,
|
part2: PrettyRelationshipDefinitions.MANY,
|
||||||
},
|
},
|
||||||
[RelationshipType.MANY_TO_ONE]: {
|
[RelationshipType.MANY_TO_ONE]: {
|
||||||
part1: PrettyRelationshipDefinitions.ONE,
|
part1: PrettyRelationshipDefinitions.MANY,
|
||||||
part2: PrettyRelationshipDefinitions.MANY,
|
part2: PrettyRelationshipDefinitions.ONE,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
let relationshipOpts1 = Object.values(PrettyRelationshipDefinitions)
|
let relationshipOpts1 = Object.values(PrettyRelationshipDefinitions)
|
||||||
let relationshipOpts2 = Object.values(PrettyRelationshipDefinitions)
|
let relationshipOpts2 = Object.values(PrettyRelationshipDefinitions)
|
||||||
|
|
||||||
let relationshipPart1 = PrettyRelationshipDefinitions.MANY
|
let relationshipPart1 = PrettyRelationshipDefinitions.ONE
|
||||||
let relationshipPart2 = PrettyRelationshipDefinitions.ONE
|
let relationshipPart2 = PrettyRelationshipDefinitions.MANY
|
||||||
|
|
||||||
let originalFromColumnName = toRelationship.name,
|
let originalFromColumnName = toRelationship.name,
|
||||||
originalToColumnName = fromRelationship.name
|
originalToColumnName = fromRelationship.name
|
||||||
|
|
|
@ -7,6 +7,7 @@ import {
|
||||||
isBBReferenceField,
|
isBBReferenceField,
|
||||||
isRelationshipField,
|
isRelationshipField,
|
||||||
LinkDocument,
|
LinkDocument,
|
||||||
|
LinkInfo,
|
||||||
RelationshipFieldMetadata,
|
RelationshipFieldMetadata,
|
||||||
RelationshipType,
|
RelationshipType,
|
||||||
Row,
|
Row,
|
||||||
|
@ -125,7 +126,23 @@ abstract class UserColumnMigrator implements ColumnMigrator {
|
||||||
protected newColumn: BBReferenceFieldMetadata
|
protected newColumn: BBReferenceFieldMetadata
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
abstract updateRow(row: Row, link: LinkDocument): void
|
abstract updateRow(row: Row, linkInfo: LinkInfo): void
|
||||||
|
|
||||||
|
pickUserTableLinkSide(link: LinkDocument): LinkInfo {
|
||||||
|
if (link.doc1.tableId === InternalTable.USER_METADATA) {
|
||||||
|
return link.doc1
|
||||||
|
} else {
|
||||||
|
return link.doc2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pickOtherTableLinkSide(link: LinkDocument): LinkInfo {
|
||||||
|
if (link.doc1.tableId === InternalTable.USER_METADATA) {
|
||||||
|
return link.doc2
|
||||||
|
} else {
|
||||||
|
return link.doc1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async doMigration(): Promise<MigrationResult> {
|
async doMigration(): Promise<MigrationResult> {
|
||||||
let oldTable = cloneDeep(this.table)
|
let oldTable = cloneDeep(this.table)
|
||||||
|
@ -137,15 +154,17 @@ abstract class UserColumnMigrator implements ColumnMigrator {
|
||||||
|
|
||||||
let links = await sdk.links.fetchWithDocument(this.table._id!)
|
let links = await sdk.links.fetchWithDocument(this.table._id!)
|
||||||
for (let link of links) {
|
for (let link of links) {
|
||||||
|
const userSide = this.pickUserTableLinkSide(link)
|
||||||
|
const otherSide = this.pickOtherTableLinkSide(link)
|
||||||
if (
|
if (
|
||||||
link.doc1.tableId !== this.table._id ||
|
otherSide.tableId !== this.table._id ||
|
||||||
link.doc1.fieldName !== this.oldColumn.name ||
|
otherSide.fieldName !== this.oldColumn.name ||
|
||||||
link.doc2.tableId !== InternalTable.USER_METADATA
|
userSide.tableId !== InternalTable.USER_METADATA
|
||||||
) {
|
) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
let row = rowsById[link.doc1.rowId]
|
let row = rowsById[otherSide.rowId]
|
||||||
if (!row) {
|
if (!row) {
|
||||||
// This can happen if the row has been deleted but the link hasn't,
|
// This can happen if the row has been deleted but the link hasn't,
|
||||||
// which was a state that was found during the initial testing of this
|
// which was a state that was found during the initial testing of this
|
||||||
|
@ -153,7 +172,7 @@ abstract class UserColumnMigrator implements ColumnMigrator {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateRow(row, link)
|
this.updateRow(row, userSide)
|
||||||
}
|
}
|
||||||
|
|
||||||
let db = context.getAppDB()
|
let db = context.getAppDB()
|
||||||
|
@ -175,20 +194,20 @@ abstract class UserColumnMigrator implements ColumnMigrator {
|
||||||
}
|
}
|
||||||
|
|
||||||
class SingleUserColumnMigrator extends UserColumnMigrator {
|
class SingleUserColumnMigrator extends UserColumnMigrator {
|
||||||
updateRow(row: Row, link: LinkDocument): void {
|
updateRow(row: Row, linkInfo: LinkInfo): void {
|
||||||
row[this.newColumn.name] = dbCore.getGlobalIDFromUserMetadataID(
|
row[this.newColumn.name] = dbCore.getGlobalIDFromUserMetadataID(
|
||||||
link.doc2.rowId
|
linkInfo.rowId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MultiUserColumnMigrator extends UserColumnMigrator {
|
class MultiUserColumnMigrator extends UserColumnMigrator {
|
||||||
updateRow(row: Row, link: LinkDocument): void {
|
updateRow(row: Row, linkInfo: LinkInfo): void {
|
||||||
if (!row[this.newColumn.name]) {
|
if (!row[this.newColumn.name]) {
|
||||||
row[this.newColumn.name] = []
|
row[this.newColumn.name] = []
|
||||||
}
|
}
|
||||||
row[this.newColumn.name].push(
|
row[this.newColumn.name].push(
|
||||||
dbCore.getGlobalIDFromUserMetadataID(link.doc2.rowId)
|
dbCore.getGlobalIDFromUserMetadataID(linkInfo.rowId)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
import { Document } from "../document"
|
import { Document } from "../document"
|
||||||
|
|
||||||
|
export interface LinkInfo {
|
||||||
|
rowId: string
|
||||||
|
fieldName: string
|
||||||
|
tableId: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface LinkDocument extends Document {
|
export interface LinkDocument extends Document {
|
||||||
type: string
|
type: string
|
||||||
doc1: {
|
doc1: LinkInfo
|
||||||
rowId: string
|
doc2: LinkInfo
|
||||||
fieldName: string
|
|
||||||
tableId: string
|
|
||||||
}
|
|
||||||
doc2: {
|
|
||||||
rowId: string
|
|
||||||
fieldName: string
|
|
||||||
tableId: string
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LinkDocumentValue {
|
export interface LinkDocumentValue {
|
||||||
|
|
Loading…
Reference in New Issue