-- Simple Migration: Remove UNIQUE constraint from referralCode in referrals table
-- Run this directly in phpMyAdmin or MySQL command line

-- Step 1: Find the unique index name
-- Check what indexes exist on referralCode
SHOW INDEX FROM `referrals` WHERE Column_name = 'referralCode';

-- Step 2: Drop the unique index (the index name is usually 'referralCode' or 'idx_referral_code')
-- Try these one by one until one works:

-- Option A: If the unique index is named 'referralCode'
ALTER TABLE `referrals` DROP INDEX `referralCode`;

-- Option B: If the unique index is named 'idx_referral_code' and is unique
-- First check if it's unique, then drop it
ALTER TABLE `referrals` DROP INDEX `idx_referral_code`;

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

-- Step 4: Verify - should show NON_UNIQUE = 1 (meaning NOT unique)
SHOW INDEX FROM `referrals` WHERE Column_name = 'referralCode';

