Ошибка Can't create table `magaz`.`products` (errno: 150 "Foreign key constraint is incorrectly formed")

Рейтинг: 0Ответов: 0Опубликовано: 11.07.2023

Имею 2 таблицы - products и categories. Делаю миграцию - выдаёт эту ошибку, но всё же создаёт таблицу, до таблицы категорий дело не доходит. products

public function up(): void
    {
        Schema::create('products', function (Blueprint $table) {
            $table->id();
            $table->timestamps();

            $table->string('name');
            $table->integer('price');
            $table->text('des');
            $table->unsignedBigInteger('category_id');
            $table->foreign('category_id')->references('id')->on('categories');
        });
    }

categories

public function up(): void
    {
        Schema::create('categories', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->timestamps();

            $table->string('name');
        });
    }

Ответы

Ответов пока нет.