В laravel ошибка при миграци: SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint

В laravel ошибка при миграции: SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table santas add constraint santas_wards_id_foreign foreign key (wards_id) references wards (id) on delete set null). Я хочу связать две таблицы между собой, но выходит эта ошибка. Мои миграции:

public function up()
    {
        Schema::create('santas', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('ward');
            $table->foreignId('wards_id')->constrained('wards');
            $table->timestamps();
        });
    }
  public function up()
    {
        Schema::create('wards', function (Blueprint $table) {
            $table->primary('id');
            $table->string('name');
            $table->string('santa');

            $table->timestamps();
        });
    }

Буду рад любой помощи в решение этой проблемы?


Ответы (0 шт):