<?php

namespace Tenant\Database\Migrations;

use CodeIgniter\Database\Migration;

/**
 * Identity/payroll-reference fields shown on the payslip PDF alongside
 * the staff member's name — all optional, manager-entered, purely
 * informational (this app records a bank account number to print on a
 * payslip; it never disburses to one — see the payroll build plan).
 * `employee_id`, `ssnit_number`, and `ghana_card_number` are each
 * tenant-unique when set (two staff shouldn't share one), but nullable
 * since a hotel may not have this on file for every employee yet.
 */
class AddIdentificationFieldsToUsers extends Migration
{
    public function up()
    {
        $this->forge->addColumn('users', [
            'employee_id' => [
                'type'       => 'VARCHAR',
                'constraint' => 30,
                'null'       => true,
                'after'      => 'basic_salary',
            ],
            'ssnit_number' => [
                'type'       => 'VARCHAR',
                'constraint' => 30,
                'null'       => true,
                'after'      => 'employee_id',
            ],
            'ghana_card_number' => [
                'type'       => 'VARCHAR',
                'constraint' => 30,
                'null'       => true,
                'after'      => 'ssnit_number',
            ],
            'bank_name' => [
                'type'       => 'VARCHAR',
                'constraint' => 100,
                'null'       => true,
                'after'      => 'ghana_card_number',
            ],
            'bank_branch' => [
                'type'       => 'VARCHAR',
                'constraint' => 100,
                'null'       => true,
                'after'      => 'bank_name',
            ],
            'bank_account_number' => [
                'type'       => 'VARCHAR',
                'constraint' => 50,
                'null'       => true,
                'after'      => 'bank_branch',
            ],
        ]);
    }

    public function down()
    {
        $this->forge->dropColumn('users', [
            'employee_id', 'ssnit_number', 'ghana_card_number',
            'bank_name', 'bank_branch', 'bank_account_number',
        ]);
    }
}
