<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CrearTablaOficina extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'ofic_id' => [
                'type' => 'INT',
                'unsigned' => true,
                'auto_increment' => true,
                'null' => false,
            ],
            'ofic_descripcion' => [
                'type' => 'VARCHAR',
                'constraint' => 150,
                'null' => false,
            ],
            'ofic_abreviatura' => [
                'type' => 'VARCHAR',
                'constraint' => 20,
                'null' => false,
            ],
            'ofic_estado' => [
                'type' => 'BOOL',
                'null' => false,
            ],
            'created_at timestamp default current_timestamp',
            'updated_at timestamp default current_timestamp on update current_timestamp'
        ]);

        $this->forge->addKey("ofic_id",true);
        $this->forge->createTable("oficina");
    }

    public function down()
    {
        $this->forge->dropTable("oficina", true);
    }
}
