aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/migrations/2022-01-02-105610_matches/up.sql
blob: 28db0dff716ea54c0f90121878a647a1ecf425f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
CREATE TYPE match_state AS ENUM ('playing', 'finished');

CREATE TABLE matches (
    id SERIAL PRIMARY KEY NOT NULL,
    state match_state NOT NULL,
    log_path text NOT NULL,
    created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX match_created_at ON matches(created_at);

CREATE TABLE match_players (
    match_id integer REFERENCES matches(id) NOT NULL,
    bot_id integer REFERENCES bots(id) NOT NULL,
    player_id integer NOT NULL,
    PRIMARY KEY (match_id, player_id)
);