Помогите, пожалуйста)Вроде нет проблем, поля одинаковые, но не хочет связывать. Последовательность правильная. Сначала создаётся users после неё сразу же mems.
Ошибка:
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `mems` add constraint `mems_user_id_foreign` foreign key (`user_id`) references `users` (`user_id`))
PDOException::("SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint")
/Applications/MAMP/htdocs/moderation/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
PDOStatement::execute()
/Applications/MAMP/htdocs/moderation/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
Вот миграция users:
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email')->nullable();
$table->string('avatar');
$table->string('password')->nullable();
$table->integer('user_id');
$table->integer('access_moderation')->nullable();
$table->integer('access_mems')->nullable();
$table->integer('access_admin')->nullable();
$table->rememberToken();
$table->timestamp('updated_at')->nullable();
$table->timestamp('created_at')->nullable();
});
Вот миграция mems
Schema::create('mems', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('img');
$table->integer('author_id');
$table->foreign('author_id')->references('user_id')->on('users');
});
PS. Поле user_id нужно для привязки авторизованного пользователя(вк)