<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('investment_plans', function (Blueprint $table) {
            if (!Schema::hasColumn('investment_plans', 'instant_reward')) {
                $table->decimal('instant_reward', 20, 4)->nullable()->after('initial_earning');
            }
            if (!Schema::hasColumn('investment_plans', 'image')) {
                $table->string('image')->nullable()->after('instant_reward');
            }
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('investment_plans', function (Blueprint $table) {
            if (Schema::hasColumn('investment_plans', 'image')) {
                $table->dropColumn('image');
            }
            if (Schema::hasColumn('investment_plans', 'instant_reward')) {
                $table->dropColumn('instant_reward');
            }
        });
    }
};
