From 85dcf3ba2fd0cf907610625399db691b274118bb Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Sun, 2 Jan 2022 16:14:03 +0100 Subject: store matches in database --- .../migrations/2022-01-02-105610_matches/down.sql | 3 +++ .../migrations/2022-01-02-105610_matches/up.sql | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 planetwars-server/migrations/2022-01-02-105610_matches/down.sql create mode 100644 planetwars-server/migrations/2022-01-02-105610_matches/up.sql (limited to 'planetwars-server/migrations') diff --git a/planetwars-server/migrations/2022-01-02-105610_matches/down.sql b/planetwars-server/migrations/2022-01-02-105610_matches/down.sql new file mode 100644 index 0000000..eadd0fa --- /dev/null +++ b/planetwars-server/migrations/2022-01-02-105610_matches/down.sql @@ -0,0 +1,3 @@ +DROP TABLE match_players; +DROP INDEX match_created_at; +DROP TABLE matches; \ No newline at end of file diff --git a/planetwars-server/migrations/2022-01-02-105610_matches/up.sql b/planetwars-server/migrations/2022-01-02-105610_matches/up.sql new file mode 100644 index 0000000..88c8c9e --- /dev/null +++ b/planetwars-server/migrations/2022-01-02-105610_matches/up.sql @@ -0,0 +1,14 @@ +CREATE TABLE matches ( + id SERIAL PRIMARY KEY, + 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) +); \ No newline at end of file -- cgit v1.2.3