Budibase/budibase · error · BadRequestError
Column "${oldColumn.name}" is a one-to-many column but "${ne
Error message
Column "${oldColumn.name}" is a one-to-many column but "${newColumn.name}" is not a single user column What it means
The target column type must match the cardinality of the old relationship. A ONE_TO_MANY relationship can only be migrated to a single user column (BB_REFERENCE_SINGLE). getColumnMigrator throws this BadRequestError when a one-to-many relationship is paired with a multi-user BB_REFERENCE target.
Source
Thrown at packages/server/src/sdk/workspace/tables/migration.ts:138
if (newColumn.subtype !== BBReferenceFieldSubType.USER) {
throw new BadRequestError(`Column "${newColumn.name}" is not a user column`)
}
if (!isRelationshipField(oldColumn)) {
throw new BadRequestError(
`Column "${oldColumn.name}" is not a user relationship`
)
}
if (oldColumn.tableId !== InternalTable.USER_METADATA) {
throw new BadRequestError(
`Column "${oldColumn.name}" is not a user relationship`
)
}
if (oldColumn.relationshipType === RelationshipType.ONE_TO_MANY) {
if (newColumn.type !== FieldType.BB_REFERENCE_SINGLE) {
throw new BadRequestError(
`Column "${oldColumn.name}" is a one-to-many column but "${newColumn.name}" is not a single user column`
)
}
return new SingleUserColumnMigrator(table, oldColumn, newColumn)
}
if (
oldColumn.relationshipType === RelationshipType.MANY_TO_MANY ||
oldColumn.relationshipType === RelationshipType.MANY_TO_ONE
) {
if (newColumn.type !== FieldType.BB_REFERENCE) {
throw new BadRequestError(
`Column "${oldColumn.name}" is a ${oldColumn.relationshipType} column but "${newColumn.name}" is not a multi user column`
)
}
return new MultiUserColumnMigrator(table, oldColumn, newColumn)
}
View on GitHub (pinned to a81a902e9a)
Solutions
- Use FieldType.BB_REFERENCE_SINGLE as the target for ONE_TO_MANY relationships
- Derive the target type from cardinality: ONE_TO_MANY -> BB_REFERENCE_SINGLE, otherwise BB_REFERENCE
- Use migrate() (not getColumnMigrator) which picks the correct type automatically
Example fix
// before
const newColumn = { name: "owner", type: FieldType.BB_REFERENCE, subtype: BBReferenceFieldSubType.USER }
// after
const newColumn = { name: "owner", type: FieldType.BB_REFERENCE_SINGLE, subtype: BBReferenceFieldSubType.USER } Defensive patterns
Strategy: validation
Validate before calling
if (oldColumn.relationshipType === RelationshipType.ONE_TO_MANY &&
newColumn.type !== FieldType.BB_REFERENCE_SINGLE) {
throw new Error("ONE_TO_MANY must migrate to a single user column")
} Prevention
- Map relationshipType to target type: ONE_TO_MANY -> BB_REFERENCE_SINGLE
- Let migrate() derive the target type from cardinality automatically
When it happens
Trigger: Invoking the migrator with oldColumn.relationshipType === RelationshipType.ONE_TO_MANY and newColumn.type === FieldType.BB_REFERENCE (multi) instead of BB_REFERENCE_SINGLE.
Common situations: Constructing migration payloads in bulk with a fixed target type without inspecting each relationship's cardinality.
Related errors
- Column "${oldColumn.name}" is a ${oldColumn.relationshipType
- Column "${oldColumn.name}" does not exist
- Column "${newColumn.name}" is not a user column
- Column "${oldColumn.name}" is not a user relationship
- Unknown migration type
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/81cb589f2e17145e.
Report an issue: GitHub.