]> git.xonotic.org Git - xonotic/xonstatdb.git/blob - tables/games.tab
Partition games through 2014.
[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 -- 2011
32 CREATE TABLE xonstat.games_2011Q2 (
33     CHECK ( create_dt >= DATE '2011-04-01' AND create_dt < DATE '2011-07-01' ) 
34 ) INHERITS (games);
35 CREATE INDEX games_2011Q2_ix001 on games_2011Q2(create_dt);
36 ALTER TABLE xonstat.games_2011Q2 OWNER TO xonstat;
37
38 CREATE TABLE xonstat.games_2011Q3 ( 
39     CHECK ( create_dt >= DATE '2011-07-01' AND create_dt < DATE '2011-10-01' ) 
40 ) INHERITS (games);
41 CREATE INDEX games_2011Q3_ix001 on games_2011Q3(create_dt);
42 ALTER TABLE xonstat.games_2011Q3 OWNER TO xonstat;
43
44 CREATE TABLE xonstat.games_2011Q4 ( 
45     CHECK ( create_dt >= DATE '2011-10-01' AND create_dt < DATE '2012-01-01' ) 
46 ) INHERITS (games);
47 CREATE INDEX games_2011Q4_ix001 on games_2011Q4(create_dt);
48 ALTER TABLE xonstat.games_2011Q4 OWNER TO xonstat;
49
50 -- 2012
51 CREATE TABLE xonstat.games_2012Q1 ( 
52     CHECK ( create_dt >= DATE '2012-01-01' AND create_dt < DATE '2012-04-01' ) 
53 ) INHERITS (games);
54 CREATE INDEX games_2012Q1_ix001 on games_2012Q1(create_dt);
55 ALTER TABLE xonstat.games_2012Q1 OWNER TO xonstat;
56
57 CREATE TABLE xonstat.games_2012Q2 ( 
58     CHECK ( create_dt >= DATE '2012-04-01' AND create_dt < DATE '2012-07-01' ) 
59 ) INHERITS (games);
60 CREATE INDEX games_2012Q2_ix001 on games_2012Q2(create_dt);
61 ALTER TABLE xonstat.games_2012Q2 OWNER TO xonstat;
62
63 CREATE TABLE xonstat.games_2012Q3 ( 
64     CHECK ( create_dt >= DATE '2012-07-01' AND create_dt < DATE '2012-10-01' ) 
65 ) INHERITS (games);
66 CREATE INDEX games_2012Q3_ix001 on games_2012Q3(create_dt);
67 ALTER TABLE xonstat.games_2012Q3 OWNER TO xonstat;
68
69 CREATE TABLE xonstat.games_2012Q4 ( 
70     CHECK ( create_dt >= DATE '2012-10-01' AND create_dt < DATE '2013-01-01' ) 
71 ) INHERITS (games);
72 CREATE INDEX games_2012Q4_ix001 on games_2012Q4(create_dt);
73 ALTER TABLE xonstat.games_2012Q4 OWNER TO xonstat;
74
75 -- 2013
76 CREATE TABLE xonstat.games_2013Q1 ( 
77     CHECK ( create_dt >= DATE '2013-01-01' AND create_dt < DATE '2013-04-01' ) 
78 ) INHERITS (games);
79 CREATE INDEX games_2013Q1_ix001 on games_2013Q1(create_dt);
80 ALTER TABLE xonstat.games_2013Q1 OWNER TO xonstat;
81
82 CREATE TABLE xonstat.games_2013Q2 ( 
83     CHECK ( create_dt >= DATE '2013-04-01' AND create_dt < DATE '2013-07-01' ) 
84 ) INHERITS (games);
85 CREATE INDEX games_2013Q2_ix001 on games_2013Q2(create_dt);
86 ALTER TABLE xonstat.games_2013Q2 OWNER TO xonstat;
87
88 CREATE TABLE xonstat.games_2013Q3 ( 
89     CHECK ( create_dt >= DATE '2013-07-01' AND create_dt < DATE '2013-10-01' ) 
90 ) INHERITS (games);
91 CREATE INDEX games_2013Q3_ix001 on games_2013Q3(create_dt);
92 ALTER TABLE xonstat.games_2013Q3 OWNER TO xonstat;
93
94 CREATE TABLE xonstat.games_2013Q4 ( 
95     CHECK ( create_dt >= DATE '2013-10-01' AND create_dt < DATE '2014-01-01' ) 
96 ) INHERITS (games);
97 CREATE INDEX games_2013Q4_ix001 on games_2013Q4(create_dt);
98 ALTER TABLE xonstat.games_2013Q4 OWNER TO xonstat;
99
100 -- 2014
101 CREATE TABLE xonstat.games_2014Q1 ( 
102     CHECK ( create_dt >= DATE '2014-01-01' AND create_dt < DATE '2014-04-01' ) 
103 ) INHERITS (games);
104 CREATE INDEX games_2014Q1_ix001 on games_2014Q1(create_dt);
105 ALTER TABLE xonstat.games_2014Q1 OWNER TO xonstat;
106
107 CREATE TABLE xonstat.games_2014Q2 ( 
108     CHECK ( create_dt >= DATE '2014-04-01' AND create_dt < DATE '2014-07-01' ) 
109 ) INHERITS (games);
110 CREATE INDEX games_2014Q2_ix001 on games_2014Q2(create_dt);
111 ALTER TABLE xonstat.games_2014Q2 OWNER TO xonstat;
112
113 CREATE TABLE xonstat.games_2014Q3 ( 
114     CHECK ( create_dt >= DATE '2014-07-01' AND create_dt < DATE '2014-10-01' ) 
115 ) INHERITS (games);
116 CREATE INDEX games_2014Q3_ix001 on games_2014Q3(create_dt);
117 ALTER TABLE xonstat.games_2014Q3 OWNER TO xonstat;
118
119 CREATE TABLE xonstat.games_2014Q4 ( 
120     CHECK ( create_dt >= DATE '2014-10-01' AND create_dt < DATE '2014-01-01' ) 
121 ) INHERITS (games);
122 CREATE INDEX games_2014Q4_ix001 on games_2014Q4(create_dt);
123 ALTER TABLE xonstat.games_2014Q4 OWNER TO xonstat;