<?php

namespace Tenant\Database\Migrations;

use CodeIgniter\Database\Migration;

/**
 * Phase 1 assumed every payment was recorded by a staff member. Phase 3's
 * Hubtel webhook writes folio_payments rows with nobody at the keyboard —
 * `recorded_by` null means "confirmed automatically via Hubtel webhook."
 */
class MakeFolioPaymentsRecordedByNullable extends Migration
{
    public function up()
    {
        $this->forge->modifyColumn('folio_payments', [
            'recorded_by' => [
                'type'       => 'INT',
                'constraint' => 11,
                'unsigned'   => true,
                'null'       => true,
            ],
        ]);
    }

    public function down()
    {
        $this->forge->modifyColumn('folio_payments', [
            'recorded_by' => [
                'type'       => 'INT',
                'constraint' => 11,
                'unsigned'   => true,
                'null'       => false,
            ],
        ]);
    }
}
