<?php namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class Create_loan_products extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id'=>['type'=>'INT','unsigned'=>true,'auto_increment'=>true],
            'name'=>['type'=>'VARCHAR','constraint'=>100],
            'slug'=>['type'=>'VARCHAR','constraint'=>80],
            'base_interest'=>['type'=>'DECIMAL','constraint'=>'10,4','default'=>0],
            'processing_fee_pct'=>['type'=>'DECIMAL','constraint'=>'10,4','default'=>0],
            'late_fee'=>['type'=>'DECIMAL','constraint'=>'12,2','default'=>0],
            'min_amount'=>['type'=>'DECIMAL','constraint'=>'12,2','default'=>0],
            'max_amount'=>['type'=>'DECIMAL','constraint'=>'12,2','default'=>0],
            'created_at'=>['type'=>'DATETIME','null'=>true],
            'updated_at'=>['type'=>'DATETIME','null'=>true],
        ]);
        $this->forge->addKey('id', true);
        $this->forge->createTable('loan_products');
    }

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