<?php namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class Create_documents extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id'=>['type'=>'BIGINT','unsigned'=>true,'auto_increment'=>true],
            'user_id'=>['type'=>'BIGINT','unsigned'=>true],
            'loan_id'=>['type'=>'BIGINT','unsigned'=>true,'null'=>true],
            'filename'=>['type'=>'VARCHAR','constraint'=>255],
            'original_name'=>['type'=>'VARCHAR','constraint'=>255,'null'=>true],
            'mime_type'=>['type'=>'VARCHAR','constraint'=>100,'null'=>true],
            'verified'=>['type'=>'VARCHAR','constraint'=>20,'default'=>'pending'],
            'uploaded_at'=>['type'=>'DATETIME','null'=>true],
        ]);
        $this->forge->addKey('id', true);
        $this->forge->createTable('documents');
    }

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