-- QUICK FIX: Add referral columns to users table
-- Run this to fix "Unknown column 'referralCode'" error

-- Step 1: Add referralCode column
ALTER TABLE `users` 
ADD COLUMN `referralCode` VARCHAR(50) NULL AFTER `contactNumber`;

-- Step 2: Add unique index for referralCode (if you get duplicate index error, skip this)
ALTER TABLE `users` 
ADD UNIQUE INDEX `idx_referral_code` (`referralCode`);

-- Step 3: Add referredByCode column
ALTER TABLE `users` 
ADD COLUMN `referredByCode` VARCHAR(50) NULL AFTER `referralCode`;

-- Step 4: Add index for referredByCode (if you get duplicate index error, skip this)
ALTER TABLE `users` 
ADD INDEX `idx_referred_by_code` (`referredByCode`);

-- Note: If you get "Duplicate column name" errors, the columns already exist - that's fine!
-- If you get "Duplicate key name" errors for indexes, the indexes already exist - that's also fine!

