-- =====================================================================
-- 07_telegram_integration.sql  —  RUN THIS ONCE
-- Adds telegram_chat_id column to profiles and adds 'telegram' to the
-- notif_channel enum for telegram notification delivery.
--
-- Run: Supabase Dashboard -> SQL Editor -> paste -> Run.
-- =====================================================================

-- 1) Add telegram_chat_id column to profiles table if it doesn't exist
ALTER TABLE public.profiles ADD COLUMN IF NOT EXISTS telegram_chat_id TEXT;

-- 2) Add 'telegram' to the notif_channel enum.
-- Since Postgres doesn't allow ALTER TYPE ... ADD VALUE inside a transaction block in some contexts,
-- running this directly in the Supabase SQL editor will work perfectly.
ALTER TYPE public.notif_channel ADD VALUE IF NOT EXISTS 'telegram';
