-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase_setup.sql
More file actions
38 lines (34 loc) · 1.28 KB
/
Copy pathdatabase_setup.sql
File metadata and controls
38 lines (34 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
-- Supabase Database Setup for SteppeGuard
CREATE TABLE IF NOT EXISTS public.observations (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
district_id TEXT, -- Changed to text to handle varying id types like 'b0e42d71-55e1-4c12-9c44-59e51c88820c' safely
district_name TEXT,
observed_at TIMESTAMPTZ DEFAULT NOW(),
fusion_score FLOAT,
risk_level TEXT,
ndvi_mean FLOAT,
dnbr_mean FLOAT,
bai_max FLOAT,
sar_change_mean FLOAT,
active_fire_points INTEGER,
lat FLOAT,
lng FLOAT
);
-- Optional: Create an index on observed_at to speed up timeframe filtering
CREATE INDEX IF NOT EXISTS idx_observations_observed_at ON public.observations (observed_at);
-- Create Predictions table as it's also queried by the AI Chat backend
CREATE TABLE IF NOT EXISTS public.predictions (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
district_id TEXT,
district_name TEXT,
horizon_hours INTEGER,
spread_probability FLOAT,
risk_level TEXT,
predicted_area_ha INTEGER,
confidence_score FLOAT,
wind_speed_ms FLOAT,
wind_dir_deg INTEGER,
predicted_at TIMESTAMPTZ DEFAULT NOW(),
timeline JSONB -- Stores the array of timeline dictionaries
);
CREATE INDEX IF NOT EXISTS idx_predictions_predicted_at ON public.predictions (predicted_at);