-- Step 1: Check what unique indexes exist on referralCode in referrals table
SHOW INDEX FROM `referrals` WHERE Column_name = 'referralCode';

-- Step 2: Based on the output, drop all unique indexes
-- (Look for indexes with Non_unique = 0)
-- Replace 'INDEX_NAME' with actual index names from Step 1
-- Example:
-- ALTER TABLE `referrals` DROP INDEX `referralCode_3`;
-- ALTER TABLE `referrals` DROP INDEX `referralCode_4`;
-- ALTER TABLE `referrals` DROP INDEX `referralCode_5`;
-- ... (drop all unique indexes you see)

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

-- Step 4: Verify - should show Non_unique = 1
SHOW INDEX FROM `referrals` WHERE Column_name = 'referralCode';

