<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateEmployeePayInfo extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'emppay_id' => [
                'type' => 'INT',
                'constraint' => 11,
                'unsigned' => true,
                'auto_increment' => true
            ],
            'employee_id' => [
                'type' => 'INT',
                'constraint' => 11,
                'unsigned' => true
            ],
            'paytype_id' => [
                'type' => 'INT',
                'constraint' => 11,
                'unsigned' => true
            ],
            'is_ATM' => [
                'type' => 'TINYINT',
                'constraint' => 1,
                'null' => false
            ],
            'savings_account' => [
                'type' => 'VARCHAR',
                'constraint' => 50,
                'null' => true
            ],
            'basic_monthly_pay' => [
                'type' => 'DECIMAL',
                'constraint' => '12,4',
                'null' => false
            ],
            'basic_semi_monthly_pay' => [
                'type' => 'DECIMAL',
                'constraint' => '12,4',
                'null' => false
            ],
            'basic_daily_pay' => [
                'type' => 'DECIMAL',
                'constraint' => '12,4',
                'null' => false
            ],
            'basic_hourly_pay' => [
                'type' => 'DECIMAL',
                'constraint' => '12,4',
                'null' => false
            ],
            'has_cola' => [
                'type' => 'TINYINT',
                'constraint' => 1,
                'null' => false
            ],
            'has_philhealth' => [
                'type' => 'TINYINT',
                'constraint' => 1,
                'null' => false
            ],
            'has_hdmf' => [
                'type' => 'TINYINT',
                'constraint' => 1,
                'null' => false
            ],
            'has_sss' => [
                'type' => 'TINYINT',
                'constraint' => 1,
                'null' => false
            ],
            'has_gsis' => [
                'type' => 'TINYINT',
                'constraint' => 1,
                'null' => false
            ],


            // Common fields
            'created_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
            'created_by' => [
                'type' => 'VARCHAR', 
                'constraint' => '20', 
                'null' => true
            ],
            'updated_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
            'updated_by' => [
                'type' => 'VARCHAR', 
                'constraint' => '20', 
                'null' => true
            ],
            'deleted_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
        ]);

        $this->forge->addKey('emppay_id', true);
        $this->forge->createTable('emp_pay_info');
    }

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