1
Error:
1005 Can’t create table 'cobranca_simples. #sql-f04_1f0' (Errno: 150) (SQL: alter table
carteira_cliente
add Constraintcarteira_cliente_carteira_id_foreign
Foreign key (carteira_id
) Referencescarteiras
(id
) on delete)
Migrations:
Schema::create('carteiras', function (Blueprint $table) {
$table->integer('id');
$table->string('descricao');
$table->timestamps();
}
);
Schema::create('carteira_cliente', function (Blueprint $table) {
$table->integer('carteira_id')->unsigned();
$table->integer('cliente_id')->unsigned();
$table->foreign('carteira_id')->references('id')
->on('carteiras')->onDelete('cascade');
$table->foreign('cliente_id')->references('id')
->on('clientes')->onDelete('cascade');
$table->primary(['carteira_id', 'cliente_id']);
}
);
Schema::create('carteira_user', function (Blueprint $table) {
$table->integer('carteira_id')->unsigned();
$table->integer('user_id')->unsigned();
$table->foreign('carteira_id')->references('id')
->on('carteiras')->onDelete('cascade');
$table->foreign('user_id')->references('id')
->on('users')->onDelete('cascade');
$table->primary(['carteira_id', 'user_id']);
}
);
And where is the Migration of the table
cobranca_simples
?– Woss
simple charge is the bank name
– André Cabral
It must be the order of creation, if you did wrong you have to change the name of the file. It’s an assumption only, only this has no way of knowing, is a local error difficult to reproduce.
– novic