<?php

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

return new class extends Migration {
    public function up(): void
    {
        Schema::create('monitorings', function (Blueprint $table) {
            $table->id();

            // pasien (user_id)
            $table->foreignId('patient_id')->constrained('users')->cascadeOnDelete();

            // siapa yang input (admin/terapis)
            $table->foreignId('created_by')->constrained('users')->cascadeOnDelete();

            // link ke penilaian GMFM
            $table->foreignId('gmfm_id')
                ->nullable()
                ->constrained('penilaian_gmfm')
                ->nullOnDelete();

            $table->date('tanggal');
            $table->text('catatan')->nullable();
            $table->integer('skor')->nullable();

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

    public function down(): void
    {
        Schema::dropIfExists('monitorings');
    }
};
