<?php

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

class CreateWorkersTable extends Migration
{
    public function up()
    {

        Schema::create('workers', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('id_user_detail')->nullable(); // Update foreign key to reference user_detail table
            $table->string('nama_pekerja');
            $table->date('tarikh_lahir');
            $table->string('no_ic_passport');
            $table->string('jantina');
            $table->string('negara_asal');
            $table->timestamps();

            // Create a foreign key reference to the user_detail table
            $table->foreign('id_user_detail')->references('id')->on('user_detail')->onDelete('set null');
        });
    }

    public function down()
    {
        Schema::dropIfExists('workers');
    }
}
