pedi3/database/migrations/2024_07_03_225341_tabla_ped...

45 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2024-03-11 19:41:52 -03:00
<?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('pedidos', function (Blueprint $table) {
$table->id();
$table->string('nombre', 100);
$table->boolean('terminado')->default(false);
$table->boolean('pagado')->default(false);
2024-03-11 19:41:52 -03:00
$table->unsignedBigInteger('barrio_id');
$table->timestamps();
2024-03-12 17:43:43 -03:00
$table->foreign('barrio_id')->references('id')->on('barrios');
$table->unique(['barrio_id','nombre']);
2024-03-11 19:41:52 -03:00
});
2024-07-09 20:09:29 -03:00
Schema::create('pedido_producto', function (Blueprint $table) {
$table->unsignedBigInteger('pedido_id');
$table->unsignedBigInteger('producto_id');
$table->unsignedInteger('cantidad');
$table->timestamps();
$table->primary(['pedido_id','producto_id']);
$table->foreign('pedido_id')->references('id')->on('pedidos');
$table->foreign('producto_id')->references('id')->on('productos');
});
2024-03-11 19:41:52 -03:00
}
/**
* Reverse the migrations.
*/
public function down(): void
{
2024-07-09 20:09:29 -03:00
Schema::dropIfExists('pedido_producto');
Schema::dropIfExists('pedidos');
2024-03-11 19:41:52 -03:00
}
};