【发布时间】:2019-08-24 20:42:48
【问题描述】:
我在 laravel 中使用外键时遇到奇怪的问题
当我使用 unsignedBigInteger 外键工作
Schema::table('posts', function (Blueprint $table) {
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
});
但如果我只是将 Datatype 编辑为
$table->*unsignedInteger('user_id');
** 或
$table->Integer('user_id');
外键不起作用
我不知道为什么会这样
【问题讨论】: