LPXian/Graph-News.AI
0
1-- SQL Script to set up tables for Daily AI News Engine2 3-- 1. Create the Articles table4CREATE TABLE IF NOT EXISTS public.articles (5 id UUID PRIMARY KEY DEFAULT gen_random_uuid(),6 title TEXT NOT NULL,7 summary TEXT,8 content TEXT, -- Final generated article content9 source_links JSONB, -- List of objects with {title, link}10 created_at TIMESTAMPTZ DEFAULT NOW(),11 news_date DATE DEFAULT CURRENT_DATE12);13 14-- 2. Create index for faster querying by date15CREATE INDEX IF NOT EXISTS idx_articles_news_date ON public.articles(news_date);16 17-- Enable Row Level Security (RLS)18ALTER TABLE public.articles ENABLE ROW LEVEL SECURITY;19 20-- Allow public read access (for frontend)21CREATE POLICY "Allow public read access" ON public.articles22 FOR SELECT USING (true);23 24-- Allow service role access (for backend insertion)25-- Note: Service role usually bypasses RLS, but policies can be added if needed.26 