Budibase/budibase · error · BadRequestError

Unknown migration type

Error message

Unknown migration type

What it means

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.

Source

Thrown at packages/server/src/sdk/workspace/tables/migration.ts:157

        `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)
  }

  throw new BadRequestError(`Unknown migration type`)
}

abstract class UserColumnMigrator<T> implements ColumnMigrator {
  constructor(
    protected table: Table,
    protected oldColumn: RelationshipFieldMetadata,
    protected newColumn: T
  ) {}

  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
    }
  }

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Inspect the table document and fix/remove the relationship column with the invalid relationshipType
  2. Upgrade Budibase to a version whose relationship types match the data in your tables
  3. Add a case for the new RelationshipType in getColumnMigrator if you introduced one
Defensive patterns

Strategy: validation

Validate before calling

const supported = [
  RelationshipType.ONE_TO_MANY,
  RelationshipType.MANY_TO_MANY,
  RelationshipType.MANY_TO_ONE,
]
if (!supported.includes(oldColumn.relationshipType)) {
  throw new Error(`Unsupported relationshipType: ${oldColumn.relationshipType}`)
}

Try / catch

try {
  await sdk.tables.migrate(table, oldName, newName)
} catch (e) {
  if (String(e.message) === "Unknown migration type") {
    // log the table document for inspection; schema data is likely corrupt
  }
}

Prevention

When it happens

Trigger: 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).

Common situations: Hand-edited or partially-migrated CouchDB table documents where relationshipType is missing/misspelled; running a newer server against tables written by an incompatible version.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/780ce3764f73f535. Report an issue: GitHub.