<?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('riwayat_prediksi', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained('users')->onDelete('cascade');

            // Data diri
            $table->string('nama');
            $table->enum('jenis_kelamin', ['L', 'P']);
            $table->integer('umur');

            // Gejala (disimpan sebagai JSON)
            $table->json('gejala');

            // Gaya hidup
            $table->enum('stres', ['ya', 'tidak']);
            $table->enum('merokok', ['ya', 'tidak']);
            $table->enum('alkohol', ['ya', 'tidak']);
            $table->enum('obat', ['ya', 'tidak']);

            // Hasil
            $table->string('hasil');

            $table->timestamps(); // created_at = waktu prediksi
        });
    }

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