diff --git a/database/migrations/2024_03_11_224041_create_productos_table.php b/database/migrations/2024_03_11_224041_create_productos_table.php index 272592d..9fe931d 100644 --- a/database/migrations/2024_03_11_224041_create_productos_table.php +++ b/database/migrations/2024_03_11_224041_create_productos_table.php @@ -23,6 +23,17 @@ public function up(): void $table->foreign('categoria_id')->references('id')->on('categorias'); $table->foreign('barrio_id')->references('id')->on('barrios'); }); + + Schema::create('producto_pedido', function (Blueprint $table) { + $table->unsignedBigInteger('pedido_id'); + $table->unsignedBigInteger('producto_id'); + $table->unsignedInteger('cantidad'); + $table->unsignedDecimal('total', 15, 8); + $table->timestamps(); + $table->primary(['pedido_id','producto_id']); + $table->foreign('pedido_id')->references('id')->on('pedidos'); + $table->foreign('producto_id')->references('id')->on('productos'); + }); } /** @@ -30,6 +41,7 @@ public function up(): void */ public function down(): void { + Schema::dropIfExists('producto_pedido'); Schema::dropIfExists('productos'); } }; diff --git a/database/migrations/2024_03_11_224437_create_productos_pedidos_table.php b/database/migrations/2024_03_11_224437_create_productos_pedidos_table.php deleted file mode 100644 index 51f50a9..0000000 --- a/database/migrations/2024_03_11_224437_create_productos_pedidos_table.php +++ /dev/null @@ -1,32 +0,0 @@ -unsignedBigInteger('pedido_id'); - $table->unsignedBigInteger('producto_id'); - $table->unsignedInteger('ammount'); - $table->timestamps(); - $table->primary(['pedido_id','producto_id']); - $table->foreign('pedido_id')->references('id')->on('pedidos'); - $table->foreign('producto_id')->references('id')->on('productos'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('productos_pedidos'); - } -}; diff --git a/database/migrations/2024_03_12_201127_create_caracteristicas_table.php b/database/migrations/2024_03_12_201127_create_caracteristicas_table.php index 5c15851..0aaf24a 100644 --- a/database/migrations/2024_03_12_201127_create_caracteristicas_table.php +++ b/database/migrations/2024_03_12_201127_create_caracteristicas_table.php @@ -17,6 +17,14 @@ public function up(): void $table->string('key', 100); $table->timestamps(); }); + + Schema::create('producto_caracteristica', function (Blueprint $table) { + $table->unsignedBigInteger('producto_id'); + $table->unsignedBigInteger('caracteristica_id'); + $table->primary(['producto_id','caracteristica_id']); + $table->foreign('producto_id')->references('id')->on('productos'); + $table->foreign('caracteristica_id')->references('id')->on('caracteristicas'); + }); } /** @@ -24,6 +32,7 @@ public function up(): void */ public function down(): void { + Schema::dropIfExists('producto_caracteristica'); Schema::dropIfExists('caracteristicas'); } }; diff --git a/database/migrations/2024_03_12_201211_create_productos_caracteristicas_table.php b/database/migrations/2024_03_12_201211_create_productos_caracteristicas_table.php deleted file mode 100644 index e3c71ba..0000000 --- a/database/migrations/2024_03_12_201211_create_productos_caracteristicas_table.php +++ /dev/null @@ -1,30 +0,0 @@ -unsignedBigInteger('producto_id'); - $table->unsignedBigInteger('caracteristica_id'); - $table->primary(['producto_id','caracteristica_id']); - $table->foreign('producto_id')->references('id')->on('productos'); - $table->foreign('caracteristica_id')->references('id')->on('caracteristicas'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('productos_caracteristicas'); - } -};