]> git.xonotic.org Git - xonotic/xonstatdb.git/blob - tables/games.tab
3f5c3e27ac37991153ef24b7ea92565e3c3f120a
[xonotic/xonstatdb.git] / tables / games.tab
1 CREATE TABLE xonstat.games
2 (
3   game_id bigserial NOT NULL,
4   start_dt timestamp without time zone NOT NULL,
5   game_type_cd character varying(10) NOT NULL,
6   server_id integer NOT NULL,
7   map_id integer NOT NULL,
8   duration interval,
9   winner integer,
10   match_id character varying(64),
11   mod character varying(64),
12   create_dt timestamp without time zone NOT NULL DEFAULT (current_timestamp at time zone 'UTC'),
13   CONSTRAINT games_pk PRIMARY KEY (game_id),
14   CONSTRAINT games_fk001 FOREIGN KEY (game_type_cd)
15       REFERENCES xonstat.cd_game_type (game_type_cd) MATCH SIMPLE
16       ON UPDATE NO ACTION ON DELETE NO ACTION,
17   CONSTRAINT games_fk002 FOREIGN KEY (server_id)
18       REFERENCES xonstat.servers (server_id) MATCH SIMPLE
19       ON UPDATE NO ACTION ON DELETE NO ACTION,
20   CONSTRAINT games_fk003 FOREIGN KEY (map_id)
21       REFERENCES xonstat.maps (map_id) MATCH SIMPLE
22       ON UPDATE NO ACTION ON DELETE NO ACTION,
23   CONSTRAINT games_uk001 UNIQUE (server_id, match_id)
24 )
25 WITH (
26   OIDS=FALSE
27 );
28 CREATE INDEX games_ix001 on games(create_dt);
29 ALTER TABLE xonstat.games OWNER TO xonstat;
30
31 CREATE TABLE xonstat.games_2011Q2 (
32     CHECK ( create_dt >= DATE '2011-04-01' AND create_dt < DATE '2011-07-01' ) 
33 ) INHERITS (games);
34 CREATE INDEX games_2011Q2_ix001 on games_2011Q2(create_dt);
35 ALTER TABLE xonstat.games_2011Q2 OWNER TO xonstat;
36
37 CREATE TABLE xonstat.games_2011Q3 ( 
38     CHECK ( create_dt >= DATE '2011-07-01' AND create_dt < DATE '2011-10-01' ) 
39 ) INHERITS (games);
40 CREATE INDEX games_2011Q3_ix001 on games_2011Q3(create_dt);
41 ALTER TABLE xonstat.games_2011Q3 OWNER TO xonstat;
42
43 CREATE TABLE xonstat.games_2011Q4 ( 
44     CHECK ( create_dt >= DATE '2011-10-01' AND create_dt < DATE '2012-01-01' ) 
45 ) INHERITS (games);
46 CREATE INDEX games_2011Q4_ix001 on games_2011Q4(create_dt);
47 ALTER TABLE xonstat.games_2011Q4 OWNER TO xonstat;
48
49 CREATE TABLE xonstat.games_2012Q1 ( 
50     CHECK ( create_dt >= DATE '2012-01-01' AND create_dt < DATE '2012-04-01' ) 
51 ) INHERITS (games);
52 CREATE INDEX games_2012Q1_ix001 on games_2012Q1(create_dt);
53 ALTER TABLE xonstat.games_2012Q1 OWNER TO xonstat;
54
55 CREATE TABLE xonstat.games_2012Q2 ( 
56     CHECK ( create_dt >= DATE '2012-04-01' AND create_dt < DATE '2012-07-01' ) 
57 ) INHERITS (games);
58 CREATE INDEX games_2012Q2_ix001 on games_2012Q2(create_dt);
59 ALTER TABLE xonstat.games_2012Q2 OWNER TO xonstat;
60
61 CREATE TABLE xonstat.games_2012Q3 ( 
62     CHECK ( create_dt >= DATE '2012-07-01' AND create_dt < DATE '2012-10-01' ) 
63 ) INHERITS (games);
64 CREATE INDEX games_2012Q3_ix001 on games_2012Q3(create_dt);
65 ALTER TABLE xonstat.games_2012Q3 OWNER TO xonstat;
66
67 CREATE TABLE xonstat.games_2012Q4 ( 
68     CHECK ( create_dt >= DATE '2012-10-01' AND create_dt < DATE '2013-01-01' ) 
69 ) INHERITS (games);
70 CREATE INDEX games_2012Q4_ix001 on games_2012Q4(create_dt);
71 ALTER TABLE xonstat.games_2012Q4 OWNER TO xonstat;
72
73 CREATE TABLE xonstat.games_2013Q1 ( 
74     CHECK ( create_dt >= DATE '2013-01-01' AND create_dt < DATE '2013-04-01' ) 
75 ) INHERITS (games);
76 CREATE INDEX games_2013Q1_ix001 on games_2013Q1(create_dt);
77 ALTER TABLE xonstat.games_2013Q1 OWNER TO xonstat;
78
79 CREATE TABLE xonstat.games_2013Q2 ( 
80     CHECK ( create_dt >= DATE '2013-04-01' AND create_dt < DATE '2013-07-01' ) 
81 ) INHERITS (games);
82 CREATE INDEX games_2013Q2_ix001 on games_2013Q2(create_dt);
83 ALTER TABLE xonstat.games_2013Q2 OWNER TO xonstat;