<?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('slot_temporali_prenotazione_tavoli', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('attivita_id')->unsigned()->nullable();
            $table->string('data_prenotazione')->nullable();
            $table->time('ora_inizio')->nullable();
            $table->time('ora_fine')->nullable();
            $table->bigInteger('tavolo_id')->unsigned()->nullable();
            $table->string('tipo')->nullable();
            $table->integer('posti_disponibili')->nullable();
            $table->timestamps();
        });
        Schema::table('slot_temporali_prenotazione_tavoli', function (Blueprint $table) {
            $table->foreign('attivita_id')->references('id')->on('attivita')->onDelete('cascade');
            $table->foreign('tavolo_id')->references('id')->on('tavolo')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('slot_temporali_prenotazione_tavoli');
    }
};
