<?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('updates', function (Blueprint $table) {
            $table->id();
            $table->string('version')->unique();
            $table->enum('type', ['major', 'minor', 'patch'])->default('patch');
            $table->string('title');
            $table->text('description')->nullable();
            $table->text('changelog')->nullable();
            $table->text('download_url')->nullable();
            $table->text('release_notes_url')->nullable();
            $table->boolean('is_available')->default(true);
            $table->boolean('requires_license')->default(true);
            $table->timestamp('released_at')->nullable();
            $table->timestamp('checked_at')->nullable();
            $table->boolean('is_installed')->default(false);
            $table->timestamp('installed_at')->nullable();
            $table->foreignId('installed_by')->nullable()->constrained('users')->onDelete('set null');
            $table->timestamps();
        });
    }

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