diff --git a/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte b/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte index 990aa736f6..230748b577 100644 --- a/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte +++ b/packages/builder/src/components/backend/Datasources/CreateEditRelationship.svelte @@ -90,6 +90,16 @@ if (inSchema(toTable, toRelate.name, originalToName)) { errObj.toCol = colError } + + let fromType, toType + if (fromPrimary && fromRelate.fieldName) { + fromType = fromTable?.schema[fromPrimary]?.type + toType = toTable?.schema[fromRelate.fieldName]?.type + } + if (fromType && toType && fromType !== toType) { + errObj.foreign = + "Column type of the foreign key must match the primary key" + } errors = errObj }