-- Migration: User and System Updates
-- Adds UID, KYC fields, and system configuration tables

ALTER TABLE users ADD COLUMN uid INT(6) ZEROFILL UNIQUE AFTER id;
ALTER TABLE users ADD COLUMN real_name VARCHAR(100) AFTER username;
ALTER TABLE users ADD COLUMN id_number VARCHAR(50) AFTER real_name;
ALTER TABLE users ADD COLUMN id_front VARCHAR(255) AFTER id_number;
ALTER TABLE users ADD COLUMN id_back VARCHAR(255) AFTER id_front;
ALTER TABLE users ADD COLUMN id_handheld VARCHAR(255) AFTER id_back;
ALTER TABLE users ADD COLUMN kyc_status ENUM('none', 'pending', 'approved', 'rejected') DEFAULT 'none' AFTER id_handheld;
ALTER TABLE users ADD COLUMN security_password VARCHAR(255) AFTER password_hash;

-- system_config might already exist from 01, but translations doesn't
CREATE TABLE IF NOT EXISTS translations (
    id INT AUTO_INCREMENT PRIMARY KEY,
    lang_code VARCHAR(10),
    trans_key VARCHAR(100),
    trans_value TEXT,
    UNIQUE KEY (lang_code, trans_key)
);

INSERT IGNORE INTO system_config (config_key, config_value) VALUES ('win_loss_rate', '50');
INSERT IGNORE INTO system_config (config_key, config_value) VALUES ('price_control_mode', 'market');
INSERT IGNORE INTO system_config (config_key, config_value) VALUES ('site_name', 'BITCrypto');