Erro:
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 cascade)
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']);
}
);
cobranca_simples
?