<?php

use App\Models\Enums\GrowthPetStateEnum;
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('growth_pet', function (Blueprint $table) {
            $table->integer('id')->primary();
            $table->integer('owner_id');
            $table->integer('vnum');

            $table->enum('state', array_column(GrowthPetStateEnum::cases(), 'value'))
                ->default(GrowthPetStateEnum::UPBRINGING)
                ->nullable();

            $table->string('name', 20)->nullable();

            $table->tinyInteger('size');
            $table->integer('level')->default(1)->nullable();
            $table->tinyInteger('level_step')->default(0)->nullable();
            $table->tinyInteger('evolution')->default(1)->nullable();
            $table->tinyInteger('type')->nullable();

            $table->integer('hp')->default(0)->nullable();
            $table->integer('sp')->default(0)->nullable();
            $table->integer('def')->default(0)->nullable();

            $table->tinyInteger('hp_apply')->default(0)->nullable();
            $table->tinyInteger('sp_apply')->default(0)->nullable();
            $table->tinyInteger('def_apply')->default(0)->nullable();
            $table->tinyInteger('age_apply')->default(0)->nullable();

            $table->binary('skill_level')->nullable();

            $table->integer('exp')->nullable();
            $table->integer('item_exp')->nullable();

            $table->dateTime('birthday')->nullable();
            $table->integer('end_time')->default(0)->nullable();
            $table->integer('max_time')->nullable();
        });
    }

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