<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateRevisiPermintaanTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id_revisi' => [
                'type'           => 'INT',
                'constraint'     => 11,
                'unsigned'       => true,
                'auto_increment' => true,
            ],
            'no_order_custom' => [
                'type'       => 'VARCHAR',
                'constraint' => '100',
            ],
            'user_id' => [
                'type'       => 'INT',
                'constraint' => 11,
                'unsigned'   => true,
            ],
            'user_name' => [
                'type'       => 'VARCHAR',
                'constraint' => '100',
            ],
            'perubahan_data' => [
                'type' => 'TEXT',
                'null' => true,
            ],
            'created_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
            'updated_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
        ]);

        $this->forge->addKey('id_revisi', true);
        $this->forge->addKey('no_order_custom');
        $this->forge->createTable('tabel_revisi');
    }

    public function down()
    {
        $this->forge->dropTable('tabel_revisi');
    }
}
