0
I am using the Multi Tenancy in Laravel, so I created the Migrations, without relationship between table was working normal, when I related that started the error.
I thought it was the execution order of the migrations, so I renamed it to execute in the correct form, but the error continued.
Migrations -> 2019_08_07_024917_list
public function up()
{
Schema::create('tbd_lista', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('nome')->nullable();
$table->timestamps();
});
}
Migrations -> 2019_08_08_024935_card
public function up()
{
Schema::create('tbd_cartao', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('nome',100)->nullable();
$table->integer('tbd_lista_id')->unsigned();
$table->foreign('tbd_lista_id')->references('id')->on('tbd_lista');
$table->longText('descricao');
$table->boolean('arquivar');
$table->dateTime('data');
$table->timestamps();
});
}
Error:
"SQLSTATE[HY000]: General error: 1215 Cannot add Foreign key Constraint (SQL: alter table tbd_cartao
add Constraint tbd_cartao_tbd_lista_id_foreign
Foreign key (tbd_lista_id
) References tbd_lista
(id
))"
I am also studying Latin :v I have to go through something similar. Next try $table->integer('tbd_lista_id')->unsigned(); for $table->bigInteger('tbd_lista_id')->unsigned();. maybe you need to erase this table from the bank in hand.
– kervincandido
Thank you very much, it worked!!!
– Vinicius Marçal