<?php namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class Create_payments extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id'=>['type'=>'BIGINT','unsigned'=>true,'auto_increment'=>true],
            'loan_id'=>['type'=>'BIGINT','unsigned'=>true],
            'due_date'=>['type'=>'DATE','null'=>true],
            'amount'=>['type'=>'DECIMAL','constraint'=>'12,2'],
            'status'=>['type'=>'VARCHAR','constraint'=>30,'default'=>'due'],
            'paid_on'=>['type'=>'DATETIME','null'=>true],
            'transaction_ref'=>['type'=>'VARCHAR','constraint'=>150,'null'=>true],
            'created_at'=>['type'=>'DATETIME','null'=>true],
        ]);
        $this->forge->addKey('id', true);
        $this->forge->createTable('payments');
    }

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