File size: 1,627 Bytes
3e9fac7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
-- Laring AI - Supabase Database Schema
-- Paste this script into the Supabase SQL Editor and click "Run".

-- 1. Table for Security Alerts (physical contact, aggression, suspicious objects)
CREATE TABLE IF NOT EXISTS security_alerts (
    id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now()) NOT NULL,
    type TEXT NOT NULL,
    message TEXT NOT NULL,
    parties JSONB DEFAULT '[]'::jsonb,
    severity TEXT DEFAULT 'medium'
);

-- Index for ordering alerts by newest first
CREATE INDEX IF NOT EXISTS idx_alerts_created_at ON security_alerts(created_at DESC);

-- 2. Table for Room Telemetry Statistics (Periodic snapshots)
CREATE TABLE IF NOT EXISTS room_statistics (
    id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now()) NOT NULL,
    people_count INTEGER NOT NULL,
    objects_detected JSONB DEFAULT '[]'::jsonb NOT NULL,
    dominant_emotion TEXT
);

-- Index for ordering stats snapshots by newest first
CREATE INDEX IF NOT EXISTS idx_stats_created_at ON room_statistics(created_at DESC);

-- 3. Table for Game Leaderboard (mimicry game high scores)
CREATE TABLE IF NOT EXISTS game_leaderboard (
    id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now()) NOT NULL,
    player_name TEXT NOT NULL,
    score INTEGER NOT NULL,
    high_score INTEGER NOT NULL
);

-- Index for ordering leaderboard from highest score to lowest
CREATE INDEX IF NOT EXISTS idx_leaderboard_score ON game_leaderboard(score DESC);