CRM Behaviour
Base schema — run first if columns are missing
Safe to run multiple times (IF NOT EXISTS). Adds all optional contact + account columns:
-- contacts: optional fields
ALTER TABLE public.contacts
ADD COLUMN IF NOT EXISTS secondary_phone text,
ADD COLUMN IF NOT EXISTS city text,
ADD COLUMN IF NOT EXISTS state text,
ADD COLUMN IF NOT EXISTS source_list_tag text,
ADD COLUMN IF NOT EXISTS seniority text,
ADD COLUMN IF NOT EXISTS contact_type text,
ADD COLUMN IF NOT EXISTS contact_status text;
-- accounts: all optional fields (enrichment + edit form)
ALTER TABLE public.accounts
ADD COLUMN IF NOT EXISTS hq_city text,
ADD COLUMN IF NOT EXISTS hq_state text,
ADD COLUMN IF NOT EXISTS hq_country text,
ADD COLUMN IF NOT EXISTS description text,
ADD COLUMN IF NOT EXISTS founded_year integer,
ADD COLUMN IF NOT EXISTS website text,
ADD COLUMN IF NOT EXISTS employee_count integer,
ADD COLUMN IF NOT EXISTS funding_stage text,
ADD COLUMN IF NOT EXISTS icp_score integer,
ADD COLUMN IF NOT EXISTS technologies text[];
Tags — one-time SQL migration
Run once in your Supabase SQL Editor to enable tags:
ALTER TABLE public.user_contacts ADD COLUMN IF NOT EXISTS tags text[] DEFAULT '{}';
Next Action Engine — one-time SQL migration
Run once to enable automatic task creation from call dispositions:
ALTER TABLE public.tasks
ADD COLUMN IF NOT EXISTS action_type text,
ADD COLUMN IF NOT EXISTS due_time text,
ADD COLUMN IF NOT EXISTS priority text DEFAULT 'Medium',
ADD COLUMN IF NOT EXISTS status text DEFAULT 'Pending';
Deals ownership — one-time SQL migration
Run once to add per-user ownership to deals:
ALTER TABLE public.deals
ADD COLUMN IF NOT EXISTS user_id uuid REFERENCES auth.users(id),
ADD COLUMN IF NOT EXISTS owner_id uuid REFERENCES auth.users(id);
-- Backfill your existing deals (replace with your user ID from Auth > Users):
-- UPDATE public.deals SET user_id = '<your-user-id>' WHERE user_id IS NULL;
Phone & Email Status — one-time SQL migration
Run once to enable phone and email status tracking on contacts:
ALTER TABLE public.user_contacts
ADD COLUMN IF NOT EXISTS phone_status text,
ADD COLUMN IF NOT EXISTS email_status text;
Settings persistence — one-time SQL migration
Run once to persist app settings (API keys, goals, stages) to the database so they survive browser clears and work across devices:
CREATE TABLE IF NOT EXISTS public.user_settings (
user_id uuid NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
setting_key text NOT NULL,
setting_value text,
updated_at timestamptz DEFAULT now(),
PRIMARY KEY (user_id, setting_key)
);
ALTER TABLE public.user_settings ENABLE ROW LEVEL SECURITY;
DROP POLICY IF EXISTS "user_settings_own" ON public.user_settings;
CREATE POLICY "user_settings_own" ON public.user_settings
FOR ALL TO authenticated USING (user_id = auth.uid()) WITH CHECK (user_id = auth.uid());
GRANT SELECT, INSERT, UPDATE, DELETE ON public.user_settings TO authenticated;
Team rep labels — one-time SQL migration
Run once to enable team mode in the Activity tab (shows each rep's email next to their entries):
CREATE OR REPLACE VIEW public.user_profiles AS
SELECT id, email FROM auth.users;
GRANT SELECT ON public.user_profiles TO authenticated;
Account Enrichment
Uses your Supabase brand-scrape edge function — no API key required. Runs in parallel: website meta scraping (description, industry, logo) + Wikidata (employee count, HQ city/country, founded year, official website) + Wikipedia (clean 2-sentence company summary). Deploy with: supabase functions deploy brand-scrape
Zoho Mail
Get credentials at api-console.zoho.com → Self Client → Scope: ZohoMail.messages.ALL,ZohoMail.folders.READ