-- Complete Database Updates for AlphaEdge Banking System
-- Run this entire script in your phpMyAdmin or MySQL client

-- 1. Add login attempt tracking columns (for login security feature)
ALTER TABLE `account` 
ADD COLUMN IF NOT EXISTS `login_attempts` INT(2) DEFAULT 0 AFTER `logins`,
ADD COLUMN IF NOT EXISTS `account_locked` TINYINT(1) DEFAULT 0 AFTER `login_attempts`,
ADD COLUMN IF NOT EXISTS `locked_at` DATETIME NULL AFTER `account_locked`;

-- 2. Add IBF and ERM billing code columns (for wire transfer feature)
ALTER TABLE `account` 
ADD COLUMN IF NOT EXISTS `ibf` VARCHAR(20) DEFAULT NULL AFTER `imf`,
ADD COLUMN IF NOT EXISTS `erm` VARCHAR(20) DEFAULT NULL AFTER `ibf`;

-- Verify the changes
SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_NAME = 'account' 
AND COLUMN_NAME IN ('login_attempts', 'account_locked', 'locked_at', 'ibf', 'erm');
