<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddIsdCodeToRewarderCountries extends Migration
{
    public function up()
    {
        if (!$this->db->fieldExists('isdcode', 'rewarder_countries')) {
            $this->forge->addColumn('rewarder_countries', [
                'isdcode' => [
                    'type' => 'VARCHAR',
                    'constraint' => 10,
                    'null' => true,
                    'after' => 'code',
                ],
            ]);
        }
    }

    public function down()
    {
        if ($this->db->fieldExists('isdcode', 'rewarder_countries')) {
            $this->forge->dropColumn('rewarder_countries', 'isdcode');
        }
    }
}
