# Database Setup Guide ## Quick Setup 1. Go to your Supabase project dashboard 2. Navigate to the SQL Editor 3. Copy and paste the contents of `database/schema.sql` and run it 4. Copy and paste the contents of `database/missing_tables.sql` and run it 5. Both scripts will create all necessary tables with proper indexes and RLS policies ## Table Structure ### Core Tables (from `schema.sql`) #### `options_flow` Stores real-time options flow data with: - Symbol, type (CALL/PUT), strike, expiration - Premium, volume, sentiment scores - Rocket score and badges - Timestamps #### `daily_analysis` Stores daily post-mortem analysis with: - Symbol performance metrics - Final scores and price changes - Flow statistics aggregated by day ### Additional Tables (from `missing_tables.sql`) #### Price Data Tables - `minute_bars_et` - Minute-level price bars with ET timezone - `daily_bars` - Daily OHLCV price data - `prices_intraday_1m` - 1-minute intraday price data - `prices_daily` - Daily price data (alternative schema) - `price_daily` - Daily price data with Ticker column - `price_1m` - 1-minute price data with Ticker column #### Options & Alerts Tables - `OptionsFlow_monthly` - Monthly options flow data (CamelCase) - `AlertStream_monthly` - Monthly alert stream data (CamelCase) - `alertstream_monthly` - Monthly alert stream data (lowercase) #### Configuration Tables - `bucket_members` - Symbol bucket/group memberships (e.g., 'SEMIS', 'BANKS') ## Row Level Security (RLS) The schema includes RLS policies that allow all operations by default. **For production**, you should create more restrictive policies based on your authentication requirements. ## Testing with Sample Data Uncomment the sample INSERT statements at the bottom of `schema.sql` to add test data. ## Next Steps After running the schema: 1. Verify tables exist in Supabase Table Editor 2. Test inserting a row via Supabase Dashboard 3. Update your `.env` file with correct Supabase credentials 4. Test the backend API endpoints