<?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('prescriptions', function (Blueprint $table) {
            $table->id();
            $table->string('name')->nullable();
            $table->text('brand')->nullable();
            $table->text('from')->nullable();
            $table->string('quantity')->nullable();
            $table->string('direction_quantity')->nullable();
            $table->string('refill_quantity')->nullable();
            $table->timestamps();
        });

        Schema::create('patient_prescription', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('patient_id')->nullable();
            $table->unsignedBigInteger('prescription_id')->nullable();
            $table->foreign('patient_id')->references('id')->on('patients');
            $table->foreign('prescription_id')->references('id')->on('prescriptions');
            $table->string('direction_one')->nullable();
            $table->text('direction_two')->nullable();
            $table->text('dont_substitute')->nullable();
            $table->text('comments')->nullable();
            $table->timestamps();
        });
    }

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