]> 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 3762240..a9a5e5a
@@ -1,13 +1,14 @@
 CREATE TABLE xonstat.games
 (
   game_id bigserial NOT NULL,
-  start_dt timestamp with time zone NOT NULL,
+  start_dt timestamp without time zone NOT NULL,
   game_type_cd character varying(10) NOT NULL,
   server_id integer NOT NULL,
-  map_id serial NOT NULL,
+  map_id integer NOT NULL,
   duration interval,
   winner integer,
-  create_dt timestamp with 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,9 +18,65 @@ 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
 );
+CREATE INDEX games_ix001 on games(create_dt);
 ALTER TABLE xonstat.games OWNER TO xonstat;
+
+CREATE TABLE xonstat.games_2011Q2 (
+    CHECK ( create_dt >= DATE '2011-04-01' AND create_dt < DATE '2011-07-01' ) 
+) INHERITS (games);
+CREATE INDEX games_2011Q2_ix001 on games_2011Q2(create_dt);
+ALTER TABLE xonstat.games_2011Q2 OWNER TO xonstat;
+
+CREATE TABLE xonstat.games_2011Q3 ( 
+    CHECK ( create_dt >= DATE '2011-07-01' AND create_dt < DATE '2011-10-01' ) 
+) INHERITS (games);
+CREATE INDEX games_2011Q3_ix001 on games_2011Q3(create_dt);
+ALTER TABLE xonstat.games_2011Q3 OWNER TO xonstat;
+
+CREATE TABLE xonstat.games_2011Q4 ( 
+    CHECK ( create_dt >= DATE '2011-10-01' AND create_dt < DATE '2012-01-01' ) 
+) INHERITS (games);
+CREATE INDEX games_2011Q4_ix001 on games_2011Q4(create_dt);
+ALTER TABLE xonstat.games_2011Q4 OWNER TO xonstat;
+
+CREATE TABLE xonstat.games_2012Q1 ( 
+    CHECK ( create_dt >= DATE '2012-01-01' AND create_dt < DATE '2012-04-01' ) 
+) INHERITS (games);
+CREATE INDEX games_2012Q1_ix001 on games_2012Q1(create_dt);
+ALTER TABLE xonstat.games_2012Q1 OWNER TO xonstat;
+
+CREATE TABLE xonstat.games_2012Q2 ( 
+    CHECK ( create_dt >= DATE '2012-04-01' AND create_dt < DATE '2012-07-01' ) 
+) INHERITS (games);
+CREATE INDEX games_2012Q2_ix001 on games_2012Q2(create_dt);
+ALTER TABLE xonstat.games_2012Q2 OWNER TO xonstat;
+
+CREATE TABLE xonstat.games_2012Q3 ( 
+    CHECK ( create_dt >= DATE '2012-07-01' AND create_dt < DATE '2012-10-01' ) 
+) INHERITS (games);
+CREATE INDEX games_2012Q3_ix001 on games_2012Q3(create_dt);
+ALTER TABLE xonstat.games_2012Q3 OWNER TO xonstat;
+
+CREATE TABLE xonstat.games_2012Q4 ( 
+    CHECK ( create_dt >= DATE '2012-10-01' AND create_dt < DATE '2013-01-01' ) 
+) INHERITS (games);
+CREATE INDEX games_2012Q4_ix001 on games_2012Q4(create_dt);
+ALTER TABLE xonstat.games_2012Q4 OWNER TO xonstat;
+
+CREATE TABLE xonstat.games_2013Q1 ( 
+    CHECK ( create_dt >= DATE '2013-01-01' AND create_dt < DATE '2013-04-01' ) 
+) INHERITS (games);
+CREATE INDEX games_2013Q1_ix001 on games_2013Q1(create_dt);
+ALTER TABLE xonstat.games_2013Q1 OWNER TO xonstat;
+
+CREATE TABLE xonstat.games_2013Q2 ( 
+    CHECK ( create_dt >= DATE '2013-04-01' AND create_dt < DATE '2013-07-01' ) 
+) INHERITS (games);
+CREATE INDEX games_2013Q2_ix001 on games_2013Q2(create_dt);
+ALTER TABLE xonstat.games_2013Q2 OWNER TO xonstat;