<?php

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

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

            $table->foreignId('user_id')->constrained();
            $table->string('name')->default("");

            // Type
            $table->string('type')->default("todo");          // To do, value
            $table->float('value')->nullable();                     // Amount of suffix
            $table->string('suffix')->nullable();                   // Habit action

            // Schedule
            $table->integer('schedule_value')->default("1");  // How many schedule_units?
            $table->string('schedule_unit')->default("day");  // Days, weeks, months

            // Goal
            $table->string('goal_type')->default('none');     // None, schedule, custom
            $table->integer('goal_value')->nullable();              // Every how many goal_units?
            $table->string('goal_unit')->nullable();                // Days, weeks, months

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

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