cambio a clave primaria compuesta

This commit is contained in:
Alejandro Tasistro 2024-03-12 17:26:47 -03:00
parent 49c0a29e95
commit 3635e29cf4
2 changed files with 2 additions and 2 deletions

View File

@ -12,11 +12,11 @@
public function up(): void public function up(): void
{ {
Schema::create('productos_pedidos', function (Blueprint $table) { Schema::create('productos_pedidos', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('pedido_id'); $table->unsignedBigInteger('pedido_id');
$table->unsignedBigInteger('producto_id'); $table->unsignedBigInteger('producto_id');
$table->unsignedInteger('ammount'); $table->unsignedInteger('ammount');
$table->timestamps(); $table->timestamps();
$table->primary(['pedido_id','producto_id']);
$table->foreign('pedido_id')->references('id')->on('pedidos'); $table->foreign('pedido_id')->references('id')->on('pedidos');
$table->foreign('producto_id')->references('id')->on('productos'); $table->foreign('producto_id')->references('id')->on('productos');
}); });

View File

@ -12,10 +12,10 @@
public function up(): void public function up(): void
{ {
Schema::create('productos_caracteristicas', function (Blueprint $table) { Schema::create('productos_caracteristicas', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('producto_id'); $table->unsignedBigInteger('producto_id');
$table->unsignedBigInteger('caracteristica_id'); $table->unsignedBigInteger('caracteristica_id');
$table->timestamps(); $table->timestamps();
$table->primary(['producto_id','caracteristica_id']);
$table->foreign('producto_id')->references('id')->on('productos'); $table->foreign('producto_id')->references('id')->on('productos');
$table->foreign('caracteristica_id')->references('id')->on('caracteristicas'); $table->foreign('caracteristica_id')->references('id')->on('caracteristicas');
}); });