<?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
    {
        Schema::table('backup_sets', function (Blueprint $table) {
            $table->softDeletes();
        });

        Schema::table('backup_items', function (Blueprint $table) {
            $table->softDeletes();
        });

        Schema::table('policy_versions', function (Blueprint $table) {
            $table->softDeletes();
        });

        Schema::table('restore_runs', function (Blueprint $table) {
            $table->softDeletes();
        });

        Schema::table('managed_environments', function (Blueprint $table) {
            $table->softDeletes();
            $table->index('lifecycle_status');
        });
    }

    public function down(): void
    {
        Schema::table('backup_sets', function (Blueprint $table) {
            $table->dropSoftDeletes();
        });

        Schema::table('backup_items', function (Blueprint $table) {
            $table->dropSoftDeletes();
        });

        Schema::table('policy_versions', function (Blueprint $table) {
            $table->dropSoftDeletes();
        });

        Schema::table('restore_runs', function (Blueprint $table) {
            $table->dropSoftDeletes();
        });

        Schema::table('managed_environments', function (Blueprint $table) {
            $table->dropSoftDeletes();
            $table->dropIndex(['lifecycle_status']);
        });
    }
};
