<?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('tenants', function (Blueprint $table) {
            $table->string('status')->default('active')->after('app_status');
            $table->softDeletes();
            $table->index('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('tenants', function (Blueprint $table) {
            $table->dropColumn('status');
            $table->dropSoftDeletes();
            $table->dropIndex(['status']);
        });
    }
};
