<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateFolioSequencesTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
            'year' => ['type' => 'SMALLINT', 'constraint' => 5, 'unsigned' => true],
            'kind' => ['type' => "ENUM('inspection','report')"],
            'last_number' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'default' => 0],
        ]);
        $this->forge->addKey('id', true);
        $this->forge->addUniqueKey(['year', 'kind']);
        $this->forge->createTable('folio_sequences');
    }

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