forked from DynCodingForKids/rgserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
641 lines (453 loc) · 14.3 KB
/
schema.sql
File metadata and controls
641 lines (453 loc) · 14.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.4.1
-- Dumped by pg_dump version 9.4.1
-- Started on 2015-05-09 22:44:30 EDT
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
--
-- TOC entry 2095 (class 1262 OID 16388)
-- Name: robotgame; Type: DATABASE; Schema: -; Owner: robot
--
CREATE DATABASE robotgame WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';
ALTER DATABASE robotgame OWNER TO robot;
\connect robotgame
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
--
-- TOC entry 184 (class 3079 OID 11861)
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- TOC entry 2098 (class 0 OID 0)
-- Dependencies: 184
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- TOC entry 172 (class 1259 OID 16418)
-- Name: fail_bots; Type: TABLE; Schema: public; Owner: robot; Tablespace:
--
CREATE TABLE fail_bots (
id integer NOT NULL,
hash character(32) NOT NULL,
code text NOT NULL
);
ALTER TABLE fail_bots OWNER TO robot;
--
-- TOC entry 173 (class 1259 OID 16424)
-- Name: fail_bots_id_seq; Type: SEQUENCE; Schema: public; Owner: robot
--
CREATE SEQUENCE fail_bots_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE fail_bots_id_seq OWNER TO robot;
--
-- TOC entry 2099 (class 0 OID 0)
-- Dependencies: 173
-- Name: fail_bots_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robot
--
ALTER SEQUENCE fail_bots_id_seq OWNED BY fail_bots.id;
--
-- TOC entry 174 (class 1259 OID 16426)
-- Name: history; Type: TABLE; Schema: public; Owner: robot; Tablespace:
--
CREATE TABLE history (
id integer NOT NULL,
match_id integer NOT NULL,
data text,
"timestamp" integer NOT NULL
);
ALTER TABLE history OWNER TO robot;
--
-- TOC entry 175 (class 1259 OID 16432)
-- Name: history_id_seq; Type: SEQUENCE; Schema: public; Owner: robot
--
CREATE SEQUENCE history_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE history_id_seq OWNER TO robot;
--
-- TOC entry 2100 (class 0 OID 0)
-- Dependencies: 175
-- Name: history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robot
--
ALTER SEQUENCE history_id_seq OWNED BY history.id;
--
-- TOC entry 176 (class 1259 OID 16434)
-- Name: matches; Type: TABLE; Schema: public; Owner: robot; Tablespace:
--
CREATE TABLE matches (
id integer NOT NULL,
r1_id integer,
r2_id integer,
winner integer,
"timestamp" integer DEFAULT date_part('epoch'::text, now()),
ranked boolean DEFAULT false,
state smallint DEFAULT 0,
r1_score integer,
r2_score integer,
r1_rating double precision,
r2_rating double precision,
seed integer DEFAULT 0,
r1_ranking integer,
r2_ranking integer,
k_factor integer DEFAULT 32,
r1_time double precision,
r2_time double precision
);
ALTER TABLE matches OWNER TO robot;
--
-- TOC entry 177 (class 1259 OID 16442)
-- Name: matches_id_seq; Type: SEQUENCE; Schema: public; Owner: robot
--
CREATE SEQUENCE matches_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE matches_id_seq OWNER TO robot;
--
-- TOC entry 2102 (class 0 OID 0)
-- Dependencies: 177
-- Name: matches_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robot
--
ALTER SEQUENCE matches_id_seq OWNED BY matches.id;
--
-- TOC entry 178 (class 1259 OID 16444)
-- Name: os_bots; Type: TABLE; Schema: public; Owner: robot; Tablespace:
--
CREATE TABLE os_bots (
id integer NOT NULL,
hash character(32) NOT NULL,
code text NOT NULL
);
ALTER TABLE os_bots OWNER TO robot;
--
-- TOC entry 179 (class 1259 OID 16450)
-- Name: os_bots_id_seq; Type: SEQUENCE; Schema: public; Owner: robot
--
CREATE SEQUENCE os_bots_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE os_bots_id_seq OWNER TO robot;
--
-- TOC entry 2104 (class 0 OID 0)
-- Dependencies: 179
-- Name: os_bots_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robot
--
ALTER SEQUENCE os_bots_id_seq OWNED BY os_bots.id;
--
-- TOC entry 180 (class 1259 OID 16452)
-- Name: robots; Type: TABLE; Schema: public; Owner: robot; Tablespace:
--
CREATE TABLE robots (
id integer NOT NULL,
user_id integer,
code text DEFAULT ''::text,
rating double precision,
name text,
saved boolean DEFAULT false,
compiled_code text DEFAULT ''::text,
passed boolean DEFAULT false,
changed_since_sbtest boolean DEFAULT true,
compiled boolean DEFAULT false,
open_source boolean DEFAULT false,
disabled boolean DEFAULT false,
automatch boolean DEFAULT true,
last_updated integer DEFAULT date_part('epoch'::text, now()),
last_opponent integer,
deleted boolean DEFAULT false,
last_rating double precision DEFAULT 1200 NOT NULL,
priority double precision DEFAULT 1.0 NOT NULL,
last_match integer,
"time" double precision DEFAULT 0 NOT NULL,
fast boolean,
short boolean,
winrate double precision DEFAULT 1.0
);
ALTER TABLE robots OWNER TO robot;
--
-- TOC entry 181 (class 1259 OID 16473)
-- Name: robots_id_seq; Type: SEQUENCE; Schema: public; Owner: robot
--
CREATE SEQUENCE robots_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE robots_id_seq OWNER TO robot;
--
-- TOC entry 2106 (class 0 OID 0)
-- Dependencies: 181
-- Name: robots_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robot
--
ALTER SEQUENCE robots_id_seq OWNED BY robots.id;
--
-- TOC entry 182 (class 1259 OID 16475)
-- Name: users; Type: TABLE; Schema: public; Owner: robot; Tablespace:
--
CREATE TABLE users (
id integer NOT NULL,
username character varying(40) NOT NULL,
pw_hash character varying(40) NOT NULL,
pw_salt text,
about text DEFAULT ''::text,
challenges integer DEFAULT 0,
vip boolean DEFAULT false,
account_type smallint DEFAULT 0,
registered_on integer DEFAULT date_part('epoch'::text, now()),
last_active integer DEFAULT 0,
extra_bots integer DEFAULT 0
);
ALTER TABLE users OWNER TO robot;
--
-- TOC entry 183 (class 1259 OID 16488)
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: robot
--
CREATE SEQUENCE users_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE users_id_seq OWNER TO robot;
--
-- TOC entry 2109 (class 0 OID 0)
-- Dependencies: 183
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: robot
--
ALTER SEQUENCE users_id_seq OWNED BY users.id;
--
-- TOC entry 1920 (class 2604 OID 16490)
-- Name: id; Type: DEFAULT; Schema: public; Owner: robot
--
ALTER TABLE ONLY fail_bots ALTER COLUMN id SET DEFAULT nextval('fail_bots_id_seq'::regclass);
--
-- TOC entry 1921 (class 2604 OID 16491)
-- Name: id; Type: DEFAULT; Schema: public; Owner: robot
--
ALTER TABLE ONLY history ALTER COLUMN id SET DEFAULT nextval('history_id_seq'::regclass);
--
-- TOC entry 1927 (class 2604 OID 16492)
-- Name: id; Type: DEFAULT; Schema: public; Owner: robot
--
ALTER TABLE ONLY matches ALTER COLUMN id SET DEFAULT nextval('matches_id_seq'::regclass);
--
-- TOC entry 1928 (class 2604 OID 16493)
-- Name: id; Type: DEFAULT; Schema: public; Owner: robot
--
ALTER TABLE ONLY os_bots ALTER COLUMN id SET DEFAULT nextval('os_bots_id_seq'::regclass);
--
-- TOC entry 1944 (class 2604 OID 16494)
-- Name: id; Type: DEFAULT; Schema: public; Owner: robot
--
ALTER TABLE ONLY robots ALTER COLUMN id SET DEFAULT nextval('robots_id_seq'::regclass);
--
-- TOC entry 1952 (class 2604 OID 16495)
-- Name: id; Type: DEFAULT; Schema: public; Owner: robot
--
ALTER TABLE ONLY users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regclass);
--
-- TOC entry 1954 (class 2606 OID 71442)
-- Name: fail_bots_hash_key; Type: CONSTRAINT; Schema: public; Owner: robot; Tablespace:
--
ALTER TABLE ONLY fail_bots
ADD CONSTRAINT fail_bots_hash_key UNIQUE (hash);
--
-- TOC entry 1956 (class 2606 OID 71444)
-- Name: fail_bots_pkey; Type: CONSTRAINT; Schema: public; Owner: robot; Tablespace:
--
ALTER TABLE ONLY fail_bots
ADD CONSTRAINT fail_bots_pkey PRIMARY KEY (id);
--
-- TOC entry 1958 (class 2606 OID 71446)
-- Name: history_pkey; Type: CONSTRAINT; Schema: public; Owner: robot; Tablespace:
--
ALTER TABLE ONLY history
ADD CONSTRAINT history_pkey PRIMARY KEY (id);
--
-- TOC entry 1963 (class 2606 OID 71448)
-- Name: matches_pkey; Type: CONSTRAINT; Schema: public; Owner: robot; Tablespace:
--
ALTER TABLE ONLY matches
ADD CONSTRAINT matches_pkey PRIMARY KEY (id);
--
-- TOC entry 1968 (class 2606 OID 71450)
-- Name: os_bots_hash_key; Type: CONSTRAINT; Schema: public; Owner: robot; Tablespace:
--
ALTER TABLE ONLY os_bots
ADD CONSTRAINT os_bots_hash_key UNIQUE (hash);
--
-- TOC entry 1970 (class 2606 OID 71452)
-- Name: os_bots_pkey; Type: CONSTRAINT; Schema: public; Owner: robot; Tablespace:
--
ALTER TABLE ONLY os_bots
ADD CONSTRAINT os_bots_pkey PRIMARY KEY (id);
--
-- TOC entry 1974 (class 2606 OID 71454)
-- Name: robots_pkey; Type: CONSTRAINT; Schema: public; Owner: robot; Tablespace:
--
ALTER TABLE ONLY robots
ADD CONSTRAINT robots_pkey PRIMARY KEY (id);
--
-- TOC entry 1977 (class 2606 OID 71456)
-- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: robot; Tablespace:
--
ALTER TABLE ONLY users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- TOC entry 1959 (class 1259 OID 71457)
-- Name: history_timestamp_idx; Type: INDEX; Schema: public; Owner: robot; Tablespace:
--
CREATE INDEX history_timestamp_idx ON history USING btree ("timestamp");
--
-- TOC entry 1960 (class 1259 OID 71458)
-- Name: match_id; Type: INDEX; Schema: public; Owner: robot; Tablespace:
--
CREATE INDEX match_id ON history USING btree (match_id);
--
-- TOC entry 1961 (class 1259 OID 71459)
-- Name: matches_id_idx; Type: INDEX; Schema: public; Owner: robot; Tablespace:
--
CREATE INDEX matches_id_idx ON matches USING btree (id) WHERE ((state = 0) OR (state = 1));
--
-- TOC entry 1964 (class 1259 OID 71460)
-- Name: matches_timestamp; Type: INDEX; Schema: public; Owner: robot; Tablespace:
--
CREATE INDEX matches_timestamp ON matches USING btree ("timestamp");
--
-- TOC entry 1965 (class 1259 OID 71461)
-- Name: r1_id; Type: INDEX; Schema: public; Owner: robot; Tablespace:
--
CREATE INDEX r1_id ON matches USING btree (r1_id);
--
-- TOC entry 1966 (class 1259 OID 71462)
-- Name: r2_id; Type: INDEX; Schema: public; Owner: robot; Tablespace:
--
CREATE INDEX r2_id ON matches USING btree (r2_id);
--
-- TOC entry 1971 (class 1259 OID 71468)
-- Name: rating; Type: INDEX; Schema: public; Owner: robot; Tablespace:
--
CREATE INDEX rating ON robots USING btree (rating);
--
-- TOC entry 1972 (class 1259 OID 71471)
-- Name: robots_id_idx; Type: INDEX; Schema: public; Owner: robot; Tablespace:
--
CREATE INDEX robots_id_idx ON robots USING btree (id) WHERE (fast OR short);
--
-- TOC entry 1975 (class 1259 OID 71472)
-- Name: user_id; Type: INDEX; Schema: public; Owner: robot; Tablespace:
--
CREATE INDEX user_id ON robots USING btree (user_id);
--
-- TOC entry 1978 (class 2606 OID 71473)
-- Name: history_match_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: robot
--
ALTER TABLE ONLY history
ADD CONSTRAINT history_match_id_fkey FOREIGN KEY (match_id) REFERENCES matches(id);
--
-- TOC entry 1979 (class 2606 OID 71478)
-- Name: matches_r1_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: robot
--
ALTER TABLE ONLY matches
ADD CONSTRAINT matches_r1_id_fkey FOREIGN KEY (r1_id) REFERENCES robots(id);
--
-- TOC entry 1980 (class 2606 OID 71483)
-- Name: matches_r2_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: robot
--
ALTER TABLE ONLY matches
ADD CONSTRAINT matches_r2_id_fkey FOREIGN KEY (r2_id) REFERENCES robots(id);
--
-- TOC entry 1981 (class 2606 OID 71488)
-- Name: robots_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: robot
--
ALTER TABLE ONLY robots
ADD CONSTRAINT robots_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE;
--
-- TOC entry 2097 (class 0 OID 0)
-- Dependencies: 6
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO robot;
GRANT ALL ON SCHEMA public TO PUBLIC;
--
-- TOC entry 2101 (class 0 OID 0)
-- Dependencies: 176
-- Name: matches; Type: ACL; Schema: public; Owner: robot
--
REVOKE ALL ON TABLE matches FROM PUBLIC;
REVOKE ALL ON TABLE matches FROM robot;
GRANT ALL ON TABLE matches TO robot;
--
-- TOC entry 2103 (class 0 OID 0)
-- Dependencies: 177
-- Name: matches_id_seq; Type: ACL; Schema: public; Owner: robot
--
REVOKE ALL ON SEQUENCE matches_id_seq FROM PUBLIC;
REVOKE ALL ON SEQUENCE matches_id_seq FROM robot;
GRANT ALL ON SEQUENCE matches_id_seq TO robot;
--
-- TOC entry 2105 (class 0 OID 0)
-- Dependencies: 180
-- Name: robots; Type: ACL; Schema: public; Owner: robot
--
REVOKE ALL ON TABLE robots FROM PUBLIC;
REVOKE ALL ON TABLE robots FROM robot;
GRANT ALL ON TABLE robots TO robot;
--
-- TOC entry 2107 (class 0 OID 0)
-- Dependencies: 181
-- Name: robots_id_seq; Type: ACL; Schema: public; Owner: robot
--
REVOKE ALL ON SEQUENCE robots_id_seq FROM PUBLIC;
REVOKE ALL ON SEQUENCE robots_id_seq FROM robot;
GRANT ALL ON SEQUENCE robots_id_seq TO robot;
--
-- TOC entry 2108 (class 0 OID 0)
-- Dependencies: 182
-- Name: users; Type: ACL; Schema: public; Owner: robot
--
REVOKE ALL ON TABLE users FROM PUBLIC;
REVOKE ALL ON TABLE users FROM robot;
GRANT ALL ON TABLE users TO robot;
--
-- TOC entry 2110 (class 0 OID 0)
-- Dependencies: 183
-- Name: users_id_seq; Type: ACL; Schema: public; Owner: robot
--
REVOKE ALL ON SEQUENCE users_id_seq FROM PUBLIC;
REVOKE ALL ON SEQUENCE users_id_seq FROM robot;
GRANT ALL ON SEQUENCE users_id_seq TO robot;
-- Completed on 2015-05-09 22:44:30 EDT
--
-- PostgreSQL database dump complete
--