2021-05-10 21:22:07 +02:00
|
|
|
CREATE TABLE `challenges` (
|
|
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
|
|
`token` int(10) unsigned NOT NULL,
|
2021-05-16 13:14:00 +02:00
|
|
|
`time_limit` int(10) unsigned,
|
2021-05-19 14:52:49 +02:00
|
|
|
`time_limit_type` enum('game', 'round') NOT NULL DEFAULT 'game',
|
2021-05-10 21:22:07 +02:00
|
|
|
`no_move` tinyint(1) NOT NULL DEFAULT 0,
|
|
|
|
`no_pan` tinyint(1) NOT NULL DEFAULT 0,
|
|
|
|
`no_zoom` tinyint(1) NOT NULL DEFAULT 0,
|
2021-05-11 09:07:05 +02:00
|
|
|
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2021-05-10 21:22:07 +02:00
|
|
|
PRIMARY KEY (`id`)
|
|
|
|
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
|
|
|
|
|
|
|
|
CREATE TABLE `user_in_challenge` (
|
|
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
|
|
`user_id` int(10) unsigned NOT NULL,
|
|
|
|
`challenge_id` int(10) unsigned NOT NULL,
|
2021-05-16 13:14:00 +02:00
|
|
|
`current_round` smallint(5) signed NOT NULL DEFAULT 0,
|
2021-05-10 21:22:07 +02:00
|
|
|
`time_left` int(10) unsigned,
|
2021-05-12 13:51:06 +02:00
|
|
|
`is_owner` tinyint(1) NOT NULL DEFAULT 0,
|
2021-05-10 21:22:07 +02:00
|
|
|
PRIMARY KEY (`id`),
|
|
|
|
KEY `user_id` (`user_id`),
|
|
|
|
KEY `challenge_id` (`challenge_id`),
|
|
|
|
CONSTRAINT `user_in_challenge_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
|
|
|
|
CONSTRAINT `user_in_challenge_challenge_id` FOREIGN KEY (`challenge_id`) REFERENCES `challenges` (`id`)
|
|
|
|
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
|
|
|
|
|
|
|
|
CREATE TABLE `place_in_challenge` (
|
|
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
|
|
`place_id` int(10) unsigned NOT NULL,
|
|
|
|
`challenge_id` int(10) unsigned NOT NULL,
|
2021-05-16 13:14:00 +02:00
|
|
|
`round` smallint(5) unsigned NOT NULL,
|
2021-05-10 21:22:07 +02:00
|
|
|
PRIMARY KEY (`id`),
|
|
|
|
KEY `place_id` (`place_id`),
|
|
|
|
KEY `challenge_id` (`challenge_id`),
|
|
|
|
CONSTRAINT `place_in_challenge_place_id` FOREIGN KEY (`place_id`) REFERENCES `places` (`id`),
|
|
|
|
CONSTRAINT `place_in_challenge_challenge_id` FOREIGN KEY (`challenge_id`) REFERENCES `challenges` (`id`),
|
2021-05-16 13:14:00 +02:00
|
|
|
CONSTRAINT `unique_order_in_challenge` UNIQUE (`round`, `challenge_id`)
|
2021-05-10 21:22:07 +02:00
|
|
|
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
|
|
|
|
|
|
|
|
CREATE TABLE `guesses` (
|
|
|
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
|
|
|
`user_id` int(10) unsigned NOT NULL,
|
|
|
|
`place_in_challenge_id` int(10) unsigned NOT NULL,
|
|
|
|
`lat` decimal(8,6) NOT NULL,
|
|
|
|
`lng` decimal(9,6) NOT NULL,
|
2021-05-12 21:01:26 +02:00
|
|
|
`score` int(10) NOT NULL,
|
|
|
|
`distance` int(10) NOT NULL,
|
2021-05-10 21:22:07 +02:00
|
|
|
`time_spent` int(10),
|
|
|
|
PRIMARY KEY (`id`),
|
|
|
|
KEY `user_id` (`user_id`),
|
|
|
|
KEY `place_in_challenge_id` (`place_in_challenge_id`),
|
2021-05-19 13:52:19 +02:00
|
|
|
CONSTRAINT `guesses_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
|
2021-05-10 21:22:07 +02:00
|
|
|
CONSTRAINT `guesses_place_in_challenge_id` FOREIGN KEY (`place_in_challenge_id`) REFERENCES `place_in_challenge` (`id`)
|
|
|
|
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
|