<?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('levels', function (Blueprint $table) {
            $table->dropColumn('plan_id');
            $table->renameColumn('amount', 'reward_amount');
            $table->string('title')->nullable()->after('id');
            $table->string('image')->nullable()->after('id');
            $table->unsignedInteger('eligibility_duration')->default(0)->comment('in days');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('levels', function (Blueprint $table) {
            $table->unsignedInteger('plan_id')->default(0);
            $table->dropColumn('title');
            $table->renameColumn('reward_amount', 'amount');
            $table->dropColumn('image');
            $table->dropColumn('eligibility_duration');
        });
    }
};
