Skip to content

Commit b92f5bc

Browse files
committed
Docu on how to ensure foreign() works
tons of people are doing it wrong every day - this should fix it or at least can be used as reference.
1 parent 926cdaa commit b92f5bc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

laravel/documentation/database/schema.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,10 @@ You may also specify options for the "on delete" and "on update" actions of the
144144

145145
You may also easily drop a foreign key constraint. The default foreign key names follow the [same convention](#dropping-indexes) as the other indexes created by the Schema builder. Here's an example:
146146

147-
$table->drop_foreign('posts_user_id_foreign');
147+
$table->drop_foreign('posts_user_id_foreign');
148+
149+
> **Note:** The field referenced in the foreign key is very likely an auto increment and therefore automatically an unsigned integer. Please make sure to create the foreign key field with **unsigned()** as both fields have to be the exact same type, the engine on both tables has to be set to **InnoDB**, and the referenced table must be created **before** the table with the foreign key.
150+
151+
$table->engine = 'InnoDB';
152+
153+
$table->integer('user_id')->unsigned();

0 commit comments

Comments
 (0)