<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class RenameStaffRoleToKasir extends Migration
{
    public function up()
    {
        $this->db->table('user')
            ->where('role', 'staff')
            ->update(['role' => 'kasir']);

        $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' => 'staff']);

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