-- V17 additive upgrade: safe to run more than once from phpMyAdmin.
-- IMPORTANT: Take a database backup before any schema change.
-- This adds only a payment-purpose discriminator; existing NayaPay wallet top-ups default to 'wallet'.
-- PHP can also apply this migration automatically if MySQL has ALTER privilege.
SET @v17_col_exists = (
 SELECT COUNT(*) FROM information_schema.COLUMNS
 WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME='nayapay_topups' AND COLUMN_NAME='payment_purpose'
);
SET @v17_sql = IF(@v17_col_exists = 0,
 'ALTER TABLE `nayapay_topups` ADD COLUMN `payment_purpose` VARCHAR(16) NOT NULL DEFAULT ''wallet''',
 'SELECT ''V17 payment_purpose already exists'' AS result');
PREPARE v17_stmt FROM @v17_sql;
EXECUTE v17_stmt;
DEALLOCATE PREPARE v17_stmt;
