This directory contains SQL migrations for the superRouter analytics features.
- Go to your Supabase project dashboard: https://supabase.com/dashboard
- Navigate to SQL Editor in the left sidebar
- Click New Query
- Copy the entire contents of
migrations/001_create_analytics_tables.sql - Paste into the SQL editor
- Click Run (or press Cmd/Ctrl + Enter)
- Verify success - you should see "Success. No rows returned"
# Install Supabase CLI if you haven't already
npm install -g supabase
# Login to Supabase
supabase login
# Link your project (get project-id from dashboard URL)
supabase link --project-ref your-project-id
# Apply the migration
supabase db push
# Or run the migration file directly
psql "postgresql://postgres:[YOUR-PASSWORD]@db.[YOUR-PROJECT-REF].supabase.co:5432/postgres" < migrations/001_create_analytics_tables.sqlIf you just want to get started quickly:
- Open your Supabase dashboard SQL Editor
- Copy and run this:
-- Create token_ai_analysis_log table
CREATE TABLE IF NOT EXISTS public.token_ai_analysis_log (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
token_mint TEXT NOT NULL,
token_symbol TEXT,
token_name TEXT,
trigger_type TEXT NOT NULL,
decision TEXT NOT NULL,
confidence NUMERIC NOT NULL,
reasoning TEXT NOT NULL,
entry_score NUMERIC,
reasons TEXT[],
warnings TEXT[],
price_usd NUMERIC,
market_cap NUMERIC,
liquidity NUMERIC,
volume_24h NUMERIC,
pump_multiple NUMERIC,
drawdown_percent NUMERIC,
resulted_in_trade BOOLEAN,
position_id TEXT,
analyzed_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- Create indexes
CREATE INDEX IF NOT EXISTS idx_token_ai_analysis_token_mint ON public.token_ai_analysis_log(token_mint);
CREATE INDEX IF NOT EXISTS idx_token_ai_analysis_analyzed_at ON public.token_ai_analysis_log(analyzed_at DESC);
CREATE INDEX IF NOT EXISTS idx_token_ai_analysis_decision ON public.token_ai_analysis_log(decision);
-- Enable RLS and create policies
ALTER TABLE public.token_ai_analysis_log ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Enable all access" ON public.token_ai_analysis_log
FOR ALL USING (true) WITH CHECK (true);After running the migration, verify the tables exist:
-- Check if tables exist
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name IN ('token_ai_analysis_log', 'token_market_snapshots');You should see both tables listed.
Make sure your .env.local has the Supabase credentials:
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-keyGet these from: Supabase Dashboard → Project Settings → API
This is fine - it means the table was already created. The migration uses IF NOT EXISTS to be safe.
Make sure you're using the service_role key or postgres password, not the anon key, when running migrations directly.
- Check that
.env.localhas the correct Supabase credentials - Restart your Next.js dev server:
npm run dev - Clear browser cache and reload
- token_ai_analysis_log: Stores every AI trading decision (buy/sell/skip) with reasoning, confidence scores, and market data at the time of decision
- token_market_snapshots: Tracks token price and market data over time for historical analysis
These power the Analytics Panel's "Recent Decisions" section and historical charts.