Más chanchullos con migraciones

This commit is contained in:
Alejandro Tasistro 2024-03-15 01:34:41 -03:00
parent 2add96ecb0
commit 9155f974b6
4 changed files with 21 additions and 62 deletions

View File

@ -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');
}
};

View File

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('productos_pedidos', function (Blueprint $table) {
$table->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');
}
};

View File

@ -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');
}
};

View File

@ -1,30 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('productos_caracteristicas', 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');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('productos_caracteristicas');
}
};