29 lines
1.5 KiB
SQL
29 lines
1.5 KiB
SQL
-- Migration: 009_patch_supplement.sql
|
|
-- Supplement context columns on grade_outcomes + unconventional_factor_data table.
|
|
-- Created: 2026-04-13
|
|
|
|
-- ============================================================
|
|
-- Add supplement columns to grade_outcomes
|
|
-- ============================================================
|
|
ALTER TABLE grade_outcomes ADD COLUMN IF NOT EXISTS coaching_context JSONB;
|
|
ALTER TABLE grade_outcomes ADD COLUMN IF NOT EXISTS redistribution_context JSONB;
|
|
ALTER TABLE grade_outcomes ADD COLUMN IF NOT EXISTS evolution_flag BOOLEAN DEFAULT FALSE;
|
|
ALTER TABLE grade_outcomes ADD COLUMN IF NOT EXISTS alt_line_opportunity JSONB;
|
|
ALTER TABLE grade_outcomes ADD COLUMN IF NOT EXISTS unconventional_factors JSONB;
|
|
|
|
-- ============================================================
|
|
-- Unconventional Factor Data (daily collection for validation)
|
|
-- ============================================================
|
|
CREATE TABLE IF NOT EXISTS unconventional_factor_data (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
factor_name TEXT NOT NULL,
|
|
game_id TEXT NOT NULL,
|
|
game_date DATE NOT NULL,
|
|
factor_value JSONB NOT NULL,
|
|
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
);
|
|
CREATE INDEX IF NOT EXISTS idx_ufd_factor ON unconventional_factor_data(factor_name);
|
|
CREATE INDEX IF NOT EXISTS idx_ufd_date ON unconventional_factor_data(game_date);
|
|
ALTER TABLE unconventional_factor_data ENABLE ROW LEVEL SECURITY;
|
|
CREATE POLICY ufd_svc ON unconventional_factor_data FOR ALL USING (auth.role() = 'service_role');
|