<?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('hcp_licenses', function (Blueprint $table) {
            $table->id('license_id'); // Creates the license_id column as an auto-incrementing primary key
            $table->unsignedBigInteger('hcp_id')->nullable(); // Define hcp_id as an unsigned big integer, allowing null
            $table->string('license_number', 50); // Define license_number as a string with a max length of 50
            $table->string('issuing_authority', 100)->nullable(); // Define issuing_authority as a string with a max length of 100, allowing null
            $table->date('issue_date')->nullable(); // Define issue_date as a date, allowing null
            $table->date('expiry_date')->nullable(); // Define expiry_date as a date, allowing null
            
            // Set up the foreign key constraint
            $table->foreign('hcp_id')->references('hcp_id')->on('hcp')->onUpdate('no action')->onDelete('no action');
        });
    }

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