You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
5.4 KiB
121 lines
5.4 KiB
PRAGMA foreign_keys=OFF; |
|
BEGIN TRANSACTION; |
|
CREATE TABLE alembic_version ( |
|
version_num VARCHAR(32) NOT NULL, |
|
CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num) |
|
); |
|
INSERT INTO alembic_version VALUES('3ef4c34115fd'); |
|
CREATE TABLE game ( |
|
id INTEGER NOT NULL, |
|
name VARCHAR(64) NOT NULL, |
|
state VARCHAR(11) DEFAULT 'hidden' NOT NULL, |
|
start_time DATETIME, |
|
end_time DATETIME, |
|
PRIMARY KEY (id), |
|
CONSTRAINT gamestate CHECK (state IN ('hidden', 'published', 'active', 'interrupted', 'finished')) |
|
); |
|
INSERT INTO game VALUES(1,'Marijns Game','hidden','2020-07-09 12:56:00.000000',NULL); |
|
INSERT INTO game VALUES(2,'Spelletje','hidden',NULL,NULL); |
|
CREATE TABLE player ( |
|
id INTEGER NOT NULL, |
|
name VARCHAR(64) NOT NULL, |
|
auth_hash VARCHAR(32), |
|
password_hash VARCHAR(128), |
|
PRIMARY KEY (id), |
|
UNIQUE (auth_hash), |
|
UNIQUE (name) |
|
); |
|
INSERT INTO player VALUES(1,'Marijn','a9df90398c66181bcb9e826e48c97d8a','pbkdf2:sha256:150000$WLe3pHiQ$ff75a3c2e8e0345be88f7f59b57f1cc27f710ef9012995b752f71d8914282cda'); |
|
INSERT INTO player VALUES(2,'Rogier','6a18131cea1be566c6a33e91349f7d91','pbkdf2:sha256:150000$YbcS3JRB$60c71304b2d148f82cd954f57d68ceb15b66fedc23bbe740cd5d97f0a60f7ce4'); |
|
INSERT INTO player VALUES(3,'Henk','df6a22a4c50abba430b82ab9e07d533e','pbkdf2:sha256:150000$PNIf5rdP$81cba639a9d12c946230411d2ba0d5bc22be4509578d7b0c9409047d907c26fc'); |
|
INSERT INTO player VALUES(4,'testplayer','79404d0d9dc869fb421c051790e74b38',NULL); |
|
INSERT INTO player VALUES(5,'test','9a9f90e959261adb50fee40b4bf0ec35',NULL); |
|
INSERT INTO player VALUES(6,'Tessa','f74c9e3d76b22368722d76a5b2445c23',NULL); |
|
INSERT INTO player VALUES(7,'Jemoeder','fc14d4b87f28da7f88c496c33b2d9fe8',NULL); |
|
INSERT INTO player VALUES(8,'jevader','a43c1704562a456bc1f098fab200805a',NULL); |
|
INSERT INTO player VALUES(9,'jekind','0e6cb60258ed1fd71a95fbd13d6751e1',NULL); |
|
CREATE TABLE game_player ( |
|
game_id INTEGER NOT NULL, |
|
player_id INTEGER NOT NULL, |
|
role VARCHAR(6) DEFAULT 'none' NOT NULL, |
|
PRIMARY KEY (game_id, player_id), |
|
FOREIGN KEY(game_id) REFERENCES game (id), |
|
FOREIGN KEY(player_id) REFERENCES player (id), |
|
CONSTRAINT role CHECK (role IN ('none', 'owner', 'hunter', 'bunny')) |
|
); |
|
INSERT INTO game_player VALUES(1,1,'owner'); |
|
INSERT INTO game_player VALUES(1,2,'hunter'); |
|
INSERT INTO game_player VALUES(1,3,'bunny'); |
|
INSERT INTO game_player VALUES(2,1,'hunter'); |
|
INSERT INTO game_player VALUES(2,3,'bunny'); |
|
INSERT INTO game_player VALUES(2,2,'owner'); |
|
CREATE TABLE location ( |
|
id INTEGER NOT NULL, |
|
player_id INTEGER NOT NULL, |
|
longitude NUMERIC(15, 10) NOT NULL, |
|
latitude NUMERIC(15, 10) NOT NULL, |
|
timestamp DATETIME DEFAULT (CURRENT_TIMESTAMP) NOT NULL, |
|
PRIMARY KEY (id), |
|
FOREIGN KEY(player_id) REFERENCES player (id) |
|
); |
|
INSERT INTO location VALUES(1,2,5.1690699999999996094,52.224429999999998131,'2020-07-10 10:36:26'); |
|
INSERT INTO location VALUES(2,2,6.0314899999999997959,52.180669999999999219,'2020-07-10 10:37:19'); |
|
INSERT INTO location VALUES(3,2,5.4217500000000002913,51.882429999999999381,'2020-07-11 10:15:12'); |
|
INSERT INTO location VALUES(4,3,4.4604499999999998038,51.905310000000000059,'2020-07-17 20:50:00'); |
|
INSERT INTO location VALUES(5,3,4.4604499999999998038,52.236209999999999808,'2020-07-17 20:50:00'); |
|
CREATE TABLE notification ( |
|
id INTEGER NOT NULL, |
|
game_id INTEGER NOT NULL, |
|
message TEXT NOT NULL, |
|
type VARCHAR(64) NOT NULL, |
|
timestamp DATETIME DEFAULT (CURRENT_TIMESTAMP) NOT NULL, |
|
PRIMARY KEY (id), |
|
FOREIGN KEY(game_id) REFERENCES game (id) |
|
); |
|
CREATE TABLE objective ( |
|
id INTEGER NOT NULL, |
|
name VARCHAR(64), |
|
game_id INTEGER NOT NULL, |
|
hash VARCHAR(32) NOT NULL, |
|
longitude NUMERIC(15, 10), |
|
latitude NUMERIC(15, 10), |
|
PRIMARY KEY (id), |
|
FOREIGN KEY(game_id) REFERENCES game (id), |
|
UNIQUE (hash) |
|
); |
|
INSERT INTO objective VALUES(1,'Je Moeder',1,'6d6ea175f38a912624b0d842230ec5a0',5.2999999999999998223,52.200000000000002843); |
|
INSERT INTO objective VALUES(5,'Amsterdam',1,'2cb430ba9120fd92ad2694ef59e8232a',4.8120099999999998985,52.37225000000000108); |
|
INSERT INTO objective VALUES(6,'Blok beton',1,'2a94b2b7ca0f01d6d6a025644ce47e46',5.2349899999999998101,52.549639999999996574); |
|
INSERT INTO objective VALUES(7,'testdit',2,'d813048690c6b804bfce0268ccd60995',5.1240500000000004376,52.093200000000003057); |
|
CREATE TABLE player_caught_player ( |
|
id INTEGER DEFAULT '-1' NOT NULL, |
|
catching_player_id INTEGER NOT NULL, |
|
caught_player_id INTEGER NOT NULL, |
|
photo_reference VARCHAR(128) NOT NULL, |
|
timestamp DATETIME DEFAULT (CURRENT_TIMESTAMP) NOT NULL, |
|
PRIMARY KEY (id), |
|
FOREIGN KEY(catching_player_id) REFERENCES player (id), |
|
FOREIGN KEY(caught_player_id) REFERENCES player (id), |
|
UNIQUE (photo_reference) |
|
); |
|
CREATE TABLE notification_player ( |
|
notification_id INTEGER NOT NULL, |
|
player_id INTEGER NOT NULL, |
|
been_shown BOOLEAN DEFAULT 'True' NOT NULL, |
|
PRIMARY KEY (notification_id, player_id), |
|
FOREIGN KEY(notification_id) REFERENCES notification (id), |
|
FOREIGN KEY(player_id) REFERENCES player (id), |
|
CHECK (been_shown IN (0, 1)) |
|
); |
|
CREATE TABLE player_found_objective ( |
|
objective_id INTEGER DEFAULT '-1' NOT NULL, |
|
player_id INTEGER DEFAULT '-1' NOT NULL, |
|
timestamp DATETIME DEFAULT (CURRENT_TIMESTAMP) NOT NULL, |
|
PRIMARY KEY (objective_id, player_id), |
|
FOREIGN KEY(objective_id) REFERENCES objective (id), |
|
FOREIGN KEY(player_id) REFERENCES player (id) |
|
); |
|
INSERT INTO player_found_objective VALUES(1,2,'2020-07-10 09:49:10'); |
|
INSERT INTO player_found_objective VALUES(1,3,'2020-07-10 09:49:10'); |
|
CREATE UNIQUE INDEX ix_game_name ON game (name); |
|
COMMIT;
|
|
|