<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('over_time_records', function (Blueprint $table) {

            $table->unsignedBigInteger('R_Status')
                  ->nullable()
                  ->after('Status');

            $table->text('Status_Remark')
                  ->nullable()
                  ->after('R_Status');

            $table->time('In_Time')
                  ->nullable()
                  ->after('Status_Remark');

            $table->time('Out_Time')
                  ->nullable()
                  ->after('In_Time');

            $table->foreign('R_Status')
                  ->references('Act_Id')
                  ->on('action_master')
                  ->onDelete('set null')
                  ->onUpdate('cascade');
        });
    }

    public function down(): void
    {
        Schema::table('over_time_records', function (Blueprint $table) {
            $table->dropForeign(['R_Status']);
            $table->dropColumn(['R_Status', 'Status_Remark', 'In_Time', 'Out_Time']);
        });
    }
};
