Я наткнулся на следующую ошибку. но мои настройки миграции кажутся правильными. Когда я использовал laravel 6,8. Миграция прошла успешно.
Я использую MySQL и Laravel 7,3.
SQLSTATE[HY000]: General error: 3780 Referencing column 'user_id' and referenced column 'id' in foreign key constraint 'cheeses_user_id_foreign' are incompatible. (SQL: alter table `cheeses` add constraint `cheeses_user_id_foreign` foreign key (`user_id`) references `users` (`id`))
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:670
669| catch (Exception $e) {
> 670| throw new QueryException(
671| $query, $this->prepareBindings($bindings), $e
672| );
673| }
class CreateUsersTable extends Migration
{
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name')->unique();
$table->string('email')->unique();
$table->bigInteger('adress');
$table->string('adress_detail');
$table->timestamp('email_verified_at')->nullable();
$table->string('password')->nullable();
$table->rememberToken();
$table->timestamps();
});
}
class CreateCheesesTable extends Migration
{
public function up()
{
Schema::create('cheeses', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users');
$table->timestamps();
});
}