<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateJasaTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' => [
                'type'           => 'INT',
                'constraint'     => 11,
                'unsigned'       => true,
                'auto_increment' => true,
            ],
            'nama_jasa' => [
                'type'       => 'VARCHAR',
                'constraint' => 150,
            ],
            'biaya' => [
                'type'       => 'BIGINT',
                'constraint' => 20,
                'unsigned'   => true,
                'default'    => 0,
            ],
            'created_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
            'updated_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
        ]);

        $this->forge->addKey('id', true);
        $this->forge->addUniqueKey('nama_jasa');
        $this->forge->createTable('jasa');
    }

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