<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

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

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

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