<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('practitioner_roles', function (Blueprint $table) {
            $table->id();
            $table->foreignId('practitioner_id')->index();
            $table->foreignId('organization_id')->index();
            $table->foreignId('speciality_id')->nullable()->index();
            $table->foreignId('identifier_id')->nullable()->index();
            $table->dateTime('period_start')->nullable();
            $table->dateTime('period_end')->nullable();
            $table->boolean('active')->default(true);

            $table->timestamps();
            $table->softDeletes();

            $table->foreignId('created_by')->nullable()->index();
            $table->foreignId('updated_by')->nullable()->index();
            $table->foreignId('deleted_by')->nullable()->index();
        });
    }

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