<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('hcp', function (Blueprint $table) {
            $table->id('hcp_id'); 
            $table->string('title', 50);
            $table->string('first_name', 50);
            $table->string('middle_name', 50)->nullable();
            $table->string('last_name', 50);
            $table->string('contact_phone_office', 20)->nullable();
            $table->string('contact_phone_personal', 20)->nullable();
            $table->string('email', 100)->nullable();
            $table->text('address')->nullable();
            $table->string('specialization', 100)->nullable();
            $table->string('school_graduated', 100)->nullable();
            $table->double('overall_rating')->nullable();
            $table->timestamps(0); 
        });

        
        DB::statement('ALTER TABLE hcp ADD CONSTRAINT hcp_overall_rating_check CHECK (overall_rating >= 0 AND overall_rating <= 5)');
    }

    public function down()
    {
      
        DB::statement('ALTER TABLE hcp DROP CONSTRAINT hcp_overall_rating_check');
        
        Schema::dropIfExists('hcp');
    }
};
