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();
|
2024-07-03 19:58:59 -03:00
|
|
|
$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');
|
2024-07-03 19:58:59 -03:00
|
|
|
$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
|
|
|
|
{
|
|
|
|
Schema::dropIfExists('pedidos');
|
2024-07-09 20:09:29 -03:00
|
|
|
Schema::dropIfExists('pedido_producto');
|
2024-03-11 19:41:52 -03:00
|
|
|
}
|
|
|
|
};
|