Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

foreignUlid with constrained() not working

Hello,

I want to use Ulid for the primary key.

But when I create the relationship in the database (while migrating), I get an error.

Foreign key constraint is incorrectly formed

It's due to ->constrained().

How can I create a key contraint with foreignUlid() ? Is it even possible ?

What other solution do I have ?

Thanks for your help.

V

1 like
1 reply
vincent15000's avatar
vincent15000
OP
Best Answer
Level 63

Well already found how to solve this.

I have to specify explicitely ->primary() for the primary key.

1 like

Please or to participate in this conversation.