<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddTotalRewardPointToUsers extends Migration
{
    public function up()
    {
        if (!$this->db->fieldExists('total_reward_point', 'users')) {
            $this->forge->addColumn('users', [
                'total_reward_point' => [
                    'type'       => 'INT',
                    'constraint' => 11,
                    'unsigned'   => true,
                    'null'       => false,
                    'default'    => 0,
                    'after'      => 'preferred_city_id',
                ],
            ]);
        }
    }

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

