{"record":{"id":"81d0c0f3437a7406","repo":"Budibase/budibase","slug":"column-oldcolumn-name-is-not-a-user-relations","errorCode":null,"errorMessage":"Column \"${oldColumn.name}\" is not a user relationship","messagePattern":"Column \"(.+?)\" is not a user relationship","errorType":"validation","errorClass":"BadRequestError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/tables/migration.ts","lineNumber":125,"sourceCode":"  }\n\n  if (!(oldColumn.name in table.schema)) {\n    throw new BadRequestError(`Column \"${oldColumn.name}\" does not exist`)\n  }\n\n  if (\n    newColumn.type !== FieldType.BB_REFERENCE_SINGLE &&\n    newColumn.type !== FieldType.BB_REFERENCE\n  ) {\n    throw new BadRequestError(`Column \"${newColumn.name}\" is not a user column`)\n  }\n\n  if (newColumn.subtype !== BBReferenceFieldSubType.USER) {\n    throw new BadRequestError(`Column \"${newColumn.name}\" is not a user column`)\n  }\n\n  if (!isRelationshipField(oldColumn)) {\n    throw new BadRequestError(\n      `Column \"${oldColumn.name}\" is not a user relationship`\n    )\n  }\n\n  if (oldColumn.tableId !== InternalTable.USER_METADATA) {\n    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  }","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/tables/migration.ts#L107-L143","documentation":"The source column of a user migration must be a relationship (LINK) column. getColumnMigrator uses the isRelationshipField type guard and throws this BadRequestError when oldColumn is not a RelationshipFieldMetadata, i.e. it's a plain field (string, number, bb reference, etc.).","triggerScenarios":"Calling the migrator with an oldColumn whose type is not FieldType.LINK - e.g. trying to \"migrate\" a text or lookup column into a user column.","commonSituations":"Scripts iterating all columns of a table without filtering to type \"link\"; misunderstanding that only relationship-to-user-column migrations are supported.","solutions":["Only pass columns where oldColumn.type === FieldType.LINK to the migrator","Filter the table schema: pick entries where isRelationshipField(col) is true","If the data lives in a non-link column, a custom data import is needed - the migrator only converts relationships"],"exampleFix":"// before\nawait migrate(table, \"ownerName\", \"owner\")\n// after\nconst col = table.schema[\"ownerName\"]\nif (col?.type === FieldType.LINK) await migrate(table, \"ownerName\", \"owner\")","handlingStrategy":"type-guard","validationCode":"if (!isRelationshipField(oldColumn)) {\n  throw new Error(`${oldColumn.name} is not a link column`)\n}","typeGuard":"const isMigratableSource = (c: FieldSchema): c is RelationshipFieldMetadata =>\n  isRelationshipField(c)","tryCatchPattern":null,"preventionTips":["Filter candidate columns with isRelationshipField before migration","Remember only FieldType.LINK columns are supported migration sources"],"tags":["bad-request","schema","relationship","migration"],"backgroundTag":"column-not-in-schema","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}