Search code examples
laravelmigrationdatabase-migrationlaravel-migrationslaravel-9

How to use foreignUuid in laravel 9


so im trying to use UUID instead of id in my table i have two tables, in both, I am using UUID to generate an id. after that, I am trying to use one id as a foreign in the second table.

Im using laravel 9

here my first table

enter image description here

and here is my second table

enter image description here

but when im trying to run php artisan migrate it show this error

enter image description here

i already trying to find on internet but still got nothing

laravel 7 using as uuid foreign key
Foreign key constraint when your primary key is UUID type column

thanks..


Solution

  • thanks, i think i solved it

    here's the way, i change my first migration like this foreignuuid laravel 9

    and my second migration foreignuuid laravel 9