]> de.git.xonotic.org Git - xonotic/xonstatdb.git/blobdiff - tables/games.tab
Add a unique constraint on server_id/match_id.
[xonotic/xonstatdb.git] / tables / games.tab
old mode 100644 (file)
new mode 100755 (executable)
index c2e3056..a9a5e5a
@@ -7,7 +7,8 @@ CREATE TABLE xonstat.games
   map_id integer NOT NULL,
   duration interval,
   winner integer,
-  create_dt timestamp without time zone NOT NULL DEFAULT now(),
+  match_id numeric,
+  create_dt timestamp without time zone NOT NULL DEFAULT (current_timestamp at time zone 'UTC'),
   CONSTRAINT games_pk PRIMARY KEY (game_id),
   CONSTRAINT games_fk001 FOREIGN KEY (game_type_cd)
       REFERENCES xonstat.cd_game_type (game_type_cd) MATCH SIMPLE
@@ -17,7 +18,8 @@ CREATE TABLE xonstat.games
       ON UPDATE NO ACTION ON DELETE NO ACTION,
   CONSTRAINT games_fk003 FOREIGN KEY (map_id)
       REFERENCES xonstat.maps (map_id) MATCH SIMPLE
-      ON UPDATE NO ACTION ON DELETE NO ACTION
+      ON UPDATE NO ACTION ON DELETE NO ACTION,
+  CONSTRAINT games_uk001 UNIQUE KEY (server_id, match_id)
 )
 WITH (
   OIDS=FALSE