Spaces:
Sleeping

File size: 1,420 Bytes
43280d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
-- Run this in your Supabase SQL editor to create the required table

CREATE TABLE IF NOT EXISTS match_results (
    id            BIGSERIAL PRIMARY KEY,
    season        TEXT NOT NULL,            -- e.g. "24/25"
    date          DATE NOT NULL,
    home_team     TEXT NOT NULL,
    away_team     TEXT NOT NULL,
    ftr           TEXT,                     -- "H" | "D" | "A"
    fthg          INTEGER,
    ftag          INTEGER,
    hthg          INTEGER,
    htag          INTEGER,
    hs            INTEGER,                  -- home shots
    as_           INTEGER,                  -- away shots
    hst           INTEGER,                  -- home shots on target
    ast           INTEGER,
    hc            INTEGER,                  -- home corners
    ac            INTEGER,
    hy            INTEGER,                  -- home yellows
    ay            INTEGER,
    hr            INTEGER,                  -- home reds
    ar            INTEGER,
    referee       TEXT,
    time_weight   FLOAT DEFAULT 1.0,
    created_at    TIMESTAMPTZ DEFAULT NOW(),
    UNIQUE (season, date, home_team, away_team)
);

-- Index for fast team lookups
CREATE INDEX IF NOT EXISTS idx_match_home ON match_results(home_team);
CREATE INDEX IF NOT EXISTS idx_match_away ON match_results(away_team);
CREATE INDEX IF NOT EXISTS idx_match_season ON match_results(season);
CREATE INDEX IF NOT EXISTS idx_match_date ON match_results(date);