<?php

namespace App\Database\Migrations\Data;

use CodeIgniter\Database\Migration;

class TanggalLibur extends Migration
{
    public function up()
    {
        $fields = [
            'id'   => ['type' => 'int', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
            'tanggal' => ['type' => 'date'],
            'title' => ['type' => 'varchar', 'constraint' => 255, 'default' => "Libur"],
            'is_nasional' =>  ['type' => 'enum', 'constraint' => ['1', '0'], 'default' => '0'],
            'created_at datetime default current_timestamp',
            'updated_at datetime default current_timestamp',
        ];

        $this->forge->addField($fields);
        $this->forge->addKey('id', true);
        $this->forge->addUniqueKey('tanggal');
        $this->forge->createTable('jadwal_libur', true);
    }

    public function down()
    {
        // drop constraints first to prevent errors
        $this->forge->dropTable('jadwal_libur', true);
    }
}
