-- QUICK FIX: Remove UNIQUE constraint from referralCode in referrals table
-- Run this in phpMyAdmin SQL tab or MySQL command line

-- Step 1: Check current indexes on referralCode
SHOW INDEX FROM `referrals` WHERE Column_name = 'referralCode';

-- Step 2: Drop the unique index/constraint
-- Based on your error, the index is named 'referralCode_3'
ALTER TABLE `referrals` DROP INDEX `referralCode_3`;

-- If the above doesn't work, check Step 1 output for the exact index name
-- Common names: 'referralCode', 'referralCode_3', 'idx_referral_code'

-- Step 3: Recreate as regular (non-unique) index for performance
CREATE INDEX `idx_referral_code` ON `referrals`(`referralCode`);

-- Step 4: Verify it's no longer unique (NON_UNIQUE should be 1)
SHOW INDEX FROM `referrals` WHERE Column_name = 'referralCode';

-- You should see NON_UNIQUE = 1, which means duplicates are now allowed!

