<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddStaffUserRole extends Migration
{
    public function up()
    {
        $this->forge->modifyColumn('user', [
            'role' => [
                'type'       => 'VARCHAR',
                'constraint' => 30,
                'default'    => 'kasir',
                'null'       => false,
            ],
        ]);
    }

    public function down()
    {
        $this->db->table('user')
            ->where('role', 'kasir')
            ->update(['role' => 'administrator']);

        $this->forge->modifyColumn('user', [
            'role' => [
                'type'       => 'VARCHAR',
                'constraint' => 30,
                'default'    => 'administrator',
                'null'       => false,
            ],
        ]);
    }
}
