<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddCountryIdToUsers extends Migration
{
    public function up()
    {
        if (!$this->db->fieldExists('countryid', 'users')) {
            $this->forge->addColumn('users', [
                'countryid' => [
                    'type' => 'INT',
                    'constraint' => 11,
                    'unsigned' => true,
                    'null' => true,
                    'after' => 'phone',
                ],
            ]);
        }
    }

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