-- Sand World referral v6
-- No new column is required. This version uses users.referred_by as the
-- one-time credit guard and Telegram /start referral links.
-- Make sure telegram_id is BIGINT UNSIGNED (schema.sql already defines it).

ALTER TABLE users MODIFY telegram_id BIGINT UNSIGNED NOT NULL;

-- Optional: turn referrals on and set the initial bonus.
INSERT INTO settings (setting_key, setting_value) VALUES
  ('referrals_enabled','true'),
  ('referral_initial_reward','100')
ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value);
