Попытка заставить мои миграции работать после переделки некоторой логики таблицы, и я сталкиваюсь с проблемой при миграции. Что-то связанное с конфликтом ограничений.
При запуске php artisan migrate:fresh
это показывает:
In Connection.php line 665:
SQLSTATE[HY000]: General error: 3780 Referencing column 'cache_id' and referenced column 'id' in
foreign key constraint 'cache_connections_cache_id_foreign' are incompatible. (SQL: alter table
`cache_connections` add constraint `cache_connections_cache_id_foreign` foreign key (`cache_id`
) references `cache` (`id`))
In Connection.php line 459:
SQLSTATE[HY000]: General error: 3780 Referencing column 'cache_id' and referenced column 'id' in
foreign key constraint 'cache_connections_cache_id_foreign' are incompatible.
Миграции:
Schema::create('cache', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('item')->unique();
$table->string('name');
$table->string('picture');
$table->string('description');
$table->unsignedInteger('connection_count');
$table->boolean('is_private');
$table->json('additional_data')->nullable();
$table->string('type_id');
$table->timestamps();
});
Schema::create('cache_connections', function (Blueprint $table) {
$table->bigInteger('cache_id');
$table->string('connection');
$table->timestamps();
$table->foreign('cache_id')
->references('id')
->on('cache')
;
});