<?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('provider_working_days', function (Blueprint $table) {
            $table->id();
            $table->foreignId('provider_id')->constrained('providers')->onDelete('cascade');
            $table->integer('day');
            $table->enum('period', ['morning', 'afternoon']);
            $table->timestamps();
            $table->softDeletes();

            $table->index('provider_id');
            $table->unique(['provider_id', 'day', 'period', 'deleted_at'], 'unique_provider_day_period');
        });
    }

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