-- ============================================================
-- CRH HMIS — Fix payment 500 error ("Data too long for mpesa_code")
-- Run this ONCE in cPanel → phpMyAdmin → (select the CRH database)
-- → SQL tab → paste → Go.
-- ============================================================
-- Widens payments.mpesa_code from VARCHAR(20) to VARCHAR(50) so cashier
-- notes longer than 20 characters no longer break the payment insert.
-- Safe and non-destructive: it only enlarges the column; existing data
-- is untouched.

ALTER TABLE `payments`
    MODIFY `mpesa_code` VARCHAR(50) NULL;

-- (Optional) verify it worked — should show 50:
-- SELECT CHARACTER_MAXIMUM_LENGTH
-- FROM information_schema.COLUMNS
-- WHERE TABLE_NAME = 'payments' AND COLUMN_NAME = 'mpesa_code';
