<?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('drugs', function (Blueprint $table) {
            $table->id();
            $table->string('code')->index();
            $table->string('name')->index();
            $table->string('generic_name')->nullable()->index();
            $table->foreignId('unit_id')->nullable();
            $table->foreignId('selling_unit_id')->index()->nullable();
            $table->text('description')->nullable();
            $table->foreignId('brand_id')->nullable();
            $table->string('mims_class')->nullable();
            $table->text('indications')->nullable();
            $table->string('atc_code')->nullable()->index();
            $table->string('segmentation')->nullable();
            $table->string('type')->nullable();
            $table->string('dosage')->nullable();
            $table->text('remark')->nullable();
            $table->string('status')->nullable();

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

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