I get this weird error when executing my constraints migration When I execute this migration I get
[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1005 Can't create table 'flowtime_dev.#sql-85bb_52' (errno: 121) (SQL: alter table `questions` add constraint questions_inventory_i
d_foreign foreign key (`inventory_id`) references `inventories` (`id`) on delete cascade)
[PDOException]
SQLSTATE[HY000]: General error: 1005 Can't create table 'flowtime_dev.#sql-85bb_52' (errno: 121)
I've read that the data types in different tables should match ( like int(10) to int(10)) and they do, this is also the last migration that I have ( all the tables exist and have been created by other migrations before).
I seriously have no idea what to do anymore :(. Could someone help? I have seen similar posts, but they have not fixed the problem so far for me.
The migration is as follows:
public function up()
{
Schema::table('questions', function ($table) {
$table->integer('inventory_id')->unsigned()->change();
$table->foreign('inventory_id')
->references('id')->on('inventories')
->onDelete('cascade');
});
Schema::table('question_response', function ($table) {
$table->integer('question_id')->unsigned()->change();
$table->foreign('question_id')
->references('id')->on('questions')
->onDelete('cascade');
});
Schema::table('question_response', function ($table) {
$table->integer('sample_result_set_id')->unsigned()->change();
$table->foreign('sample_result_set_id')
->references('id')->on('sample_response_set')
->onDelete('cascade');
});
Schema::table('inventory_response', function ($table) {
$table->integer('inventory_id')->unsigned()->change();
$table->foreign('inventory_id')
->references('id')->on('inventories')
->onDelete('cascade');
});
Schema::table('inventory_response', function ($table) {
$table->integer('sample_result_set_id')->unsigned()->change();
$table->foreign('sample_result_set_id')
->references('id')->on('sample_response_set')
->onDelete('cascade');
});
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire