{"record":{"id":"c536a6b5455a07d9","repo":"Budibase/budibase","slug":"column-oldcolumn-name-is-a-oldcolumn-relati","errorCode":null,"errorMessage":"Column \"${oldColumn.name}\" is a ${oldColumn.relationshipType} column but \"${newColumn.name}\" is not a multi user column","messagePattern":"Column \"(.+?)\" is a (.+?) column but \"(.+?)\" is not a multi user column","errorType":"validation","errorClass":"BadRequestError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/tables/migration.ts","lineNumber":149,"sourceCode":"    throw new BadRequestError(\n      `Column \"${oldColumn.name}\" is not a user relationship`\n    )\n  }\n\n  if (oldColumn.relationshipType === RelationshipType.ONE_TO_MANY) {\n    if (newColumn.type !== FieldType.BB_REFERENCE_SINGLE) {\n      throw new BadRequestError(\n        `Column \"${oldColumn.name}\" is a one-to-many column but \"${newColumn.name}\" is not a single user column`\n      )\n    }\n    return new SingleUserColumnMigrator(table, oldColumn, newColumn)\n  }\n  if (\n    oldColumn.relationshipType === RelationshipType.MANY_TO_MANY ||\n    oldColumn.relationshipType === RelationshipType.MANY_TO_ONE\n  ) {\n    if (newColumn.type !== FieldType.BB_REFERENCE) {\n      throw new BadRequestError(\n        `Column \"${oldColumn.name}\" is a ${oldColumn.relationshipType} column but \"${newColumn.name}\" is not a multi user column`\n      )\n    }\n\n    return new MultiUserColumnMigrator(table, oldColumn, newColumn)\n  }\n\n  throw new BadRequestError(`Unknown migration type`)\n}\n\nabstract class UserColumnMigrator<T> implements ColumnMigrator {\n  constructor(\n    protected table: Table,\n    protected oldColumn: RelationshipFieldMetadata,\n    protected newColumn: T\n  ) {}\n\n  abstract updateRow(row: Row, linkInfo: LinkInfo): void","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/tables/migration.ts#L131-L167","documentation":"MANY_TO_MANY and MANY_TO_ONE relationships can hold multiple users, so the target must be the multi-user column type (BB_REFERENCE). getColumnMigrator throws this BadRequestError when these relationships are paired with a BB_REFERENCE_SINGLE target.","triggerScenarios":"Invoking the migrator with oldColumn.relationshipType of MANY_TO_MANY or MANY_TO_ONE and newColumn.type === FieldType.BB_REFERENCE_SINGLE instead of FieldType.BB_REFERENCE.","commonSituations":"Reusing a single-user target column definition across multiple relationships of differing cardinality in a batch migration.","solutions":["Use FieldType.BB_REFERENCE (with constraints.type \"array\") as the target for MANY_TO_MANY / MANY_TO_ONE relationships","Derive the target type from oldColumn.relationshipType before constructing newColumn","Let the top-level migrate() function determine the correct type from cardinality"],"exampleFix":"// before\nconst newColumn = { name: \"members\", type: FieldType.BB_REFERENCE_SINGLE, subtype: BBReferenceFieldSubType.USER }\n// after\nconst newColumn = { name: \"members\", type: FieldType.BB_REFERENCE, subtype: BBReferenceFieldSubType.USER, constraints: { type: \"array\" } }","handlingStrategy":"validation","validationCode":"if ((oldColumn.relationshipType === RelationshipType.MANY_TO_MANY ||\n     oldColumn.relationshipType === RelationshipType.MANY_TO_ONE) &&\n    newColumn.type !== FieldType.BB_REFERENCE) {\n  throw new Error(\"Multi relationships must migrate to a multi user column\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Map relationshipType to target type: MANY_TO_MANY/MANY_TO_ONE -> BB_REFERENCE","Include constraints: { type: \"array\" } on multi user target columns"],"tags":["bad-request","schema","cardinality","migration"],"backgroundTag":"invalid-field-type","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}