<?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
    {
        if (! Schema::hasTable('backup_schedules') || ! Schema::hasColumn('backup_schedules', 'retention_keep_last')) {
            return;
        }

        Schema::table('backup_schedules', function (Blueprint $table): void {
            $table->integer('retention_keep_last')->nullable()->default(30)->change();
        });
    }

    public function down(): void
    {
        if (! Schema::hasTable('backup_schedules') || ! Schema::hasColumn('backup_schedules', 'retention_keep_last')) {
            return;
        }

        Schema::table('backup_schedules', function (Blueprint $table): void {
            $table->integer('retention_keep_last')->nullable(false)->default(30)->change();
        });
    }
};
