-- Migration: Add rewardLevel column to referral_rewards table for multi-level referral tracking
-- This allows tracking which level in the referral chain each reward is for

-- Add rewardLevel column if it doesn't exist
ALTER TABLE referral_rewards 
ADD COLUMN IF NOT EXISTS rewardLevel INT DEFAULT 1 
COMMENT 'Level in referral chain (1 = direct referral, 2 = parent, 3 = grandparent, etc.)';

-- Update existing rewards to have level 1 (direct referrals)
UPDATE referral_rewards 
SET rewardLevel = 1 
WHERE rewardLevel IS NULL;
