-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.sql
42 lines (35 loc) · 1.03 KB
/
reset.sql
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
\set user sam
\set schema test
\c bloop :"user"
DROP SCHEMA IF EXISTS :"schema" CASCADE;
CREATE SCHEMA test AUTHORIZATION :"user";
SET search_path TO :"schema";
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE TABLE player
(
player_id bigserial,
"name" text NOT NULL,
google_play_id text NOT NULL,
firebase_token text,
CONSTRAINT player_pk
PRIMARY KEY (player_id)
);
CREATE TABLE flag
(
flag_id bigserial,
player_id bigint NOT NULL,
"location" geography(point, 4326) NOT NULL,
color int NOT NULL,
time_placed timestamp with time zone NOT NULL DEFAULT now(),
is_captured boolean NOT NULL DEFAULT FALSE,
time_captured timestamp with time zone,
capturing_player_id bigint,
CONSTRAINT flag_pk
PRIMARY KEY (flag_id),
CONSTRAINT flag_player_id_fk
FOREIGN KEY (player_id)
REFERENCES player (player_id),
CONSTRAINT capturing_player_id_fk
FOREIGN KEY (capturing_player_id)
REFERENCES player (player_id)
);