<?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('emp_histories', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('emp_id');
            $table->unsignedBigInteger('shift_id');
            $table->timestamp('from_date')->useCurrent();
            $table->timestamp('to_date')->nullable();
            $table->timestamp('created_at')->useCurrent();
            
            $table->foreign('emp_id')->references('emp_id')->on('staff');
            $table->foreign('shift_id')->references('shift_id')->on('shifts');
        });
    }

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