У меня проблема с миграцией. Таблица ниже.
public function up()
{
Schema::create('users_articles_likes', function (Blueprint $table) {
// $table->increments('id');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users');
$table->integer('article_id')->unsigned();
$table->foreign('article_id')->references('id')->on('articles');
$table->primary(['user_id', 'article_id']);
$table->timestamps();
});
}
Когда я пытаюсь его перенести. Это не толкает всю таблицу. Просто нажимает user_id
и article_id
и эту ошибку я отображаю в терминале.
SQLSTATE [HY000]: общая ошибка: 1215 Невозможно добавить ограничение внешнего ключа
(SQL: изменить таблицу users_articles_likes
добавить ограничение
users_articles_likes_user_id_foreign
внешний ключ (user_id
)
ссылки users
(id
))
Пользователь Таблица
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});