{"record":{"id":"780ce3764f73f535","repo":"Budibase/budibase","slug":"unknown-migration-type","errorCode":null,"errorMessage":"Unknown migration type","messagePattern":"Unknown migration type","errorType":"validation","errorClass":"BadRequestError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/tables/migration.ts","lineNumber":157,"sourceCode":"        `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\n\n  pickUserTableLinkSide(link: LinkDocument): LinkInfo {\n    if (link.doc1.tableId === InternalTable.USER_METADATA) {\n      return link.doc1\n    } else {\n      return link.doc2\n    }\n  }","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/tables/migration.ts#L139-L175","documentation":"This is the exhaustive-fallback guard of getColumnMigrator. After checking ONE_TO_MANY, MANY_TO_MANY and MANY_TO_ONE, any other relationshipType value reaches the final throw of a BadRequestError. In practice it's unreachable with valid RelationshipType values, but it protects against corrupt schema data or a new relationship type added without a migrator.","triggerScenarios":"An oldColumn relationship field with a relationshipType value not covered by the three supported types (corrupted schema document in CouchDB, or a newly introduced RelationshipType not yet handled).","commonSituations":"Hand-edited or partially-migrated CouchDB table documents where relationshipType is missing/misspelled; running a newer server against tables written by an incompatible version.","solutions":["Inspect the table document and fix/remove the relationship column with the invalid relationshipType","Upgrade Budibase to a version whose relationship types match the data in your tables","Add a case for the new RelationshipType in getColumnMigrator if you introduced one"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const supported = [\n  RelationshipType.ONE_TO_MANY,\n  RelationshipType.MANY_TO_MANY,\n  RelationshipType.MANY_TO_ONE,\n]\nif (!supported.includes(oldColumn.relationshipType)) {\n  throw new Error(`Unsupported relationshipType: ${oldColumn.relationshipType}`)\n}","typeGuard":null,"tryCatchPattern":"try {\n  await sdk.tables.migrate(table, oldName, newName)\n} catch (e) {\n  if (String(e.message) === \"Unknown migration type\") {\n    // log the table document for inspection; schema data is likely corrupt\n  }\n}","preventionTips":["Validate relationshipType values before running migrations","Watch for schema corruption or new RelationshipType values after upgrades"],"tags":["bad-request","schema","fallback","migration"],"backgroundTag":"unknown-migration-type","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}