<?php

namespace Tenant\Database\Migrations;

use CodeIgniter\Database\Migration;

/**
 * A staff member's current standard monthly salary — manager-editable,
 * used only to pre-fill new payslips when a payroll run is generated
 * (see PayrollController::create()). Never silently recalculated
 * elsewhere; a payslip's own `basic_salary` value is frozen at
 * generation time (see CreatePayslipsTable) and editing this field
 * afterward does not rewrite past payslips.
 */
class AddBasicSalaryToUsers extends Migration
{
    public function up()
    {
        $this->forge->addColumn('users', [
            'basic_salary' => [
                'type'       => 'DECIMAL',
                'constraint' => '10,2',
                'null'       => true,
                'after'      => 'photo_path',
            ],
        ]);
    }

    public function down()
    {
        $this->forge->dropColumn('users', 'basic_salary');
    }
}
