<?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::table('request_descarga_programada', function (Blueprint $table) {
            $table->integer('retry_count')->default(0)->after('error_message');
            $table->timestamp('last_retry_at')->nullable()->after('retry_count');
            $table->timestamp('next_retry_at')->nullable()->after('last_retry_at');
            $table->json('downloaded_packages')->nullable()->after('next_retry_at');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('request_descarga_programada', function (Blueprint $table) {
            $table->dropColumn(['retry_count', 'last_retry_at', 'next_retry_at', 'downloaded_packages']);
        });
    }
};
