<?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('custom_schedules_specialities', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('custom_schedule_id')->index();
            $table->unsignedBigInteger('speciality_id')->index();
            $table->timestamps();
            $table->softDeletes();

            $table->foreign('custom_schedule_id')->references('id')->on('custom_schedules')->onDelete('cascade');
            $table->foreign('speciality_id')->references('id')->on('specialities')->onDelete('set null');
        });
    }

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