-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtables.sql
74 lines (74 loc) · 2.29 KB
/
tables.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
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
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
--
-- Table structure for table `leaderboard`
--
CREATE TABLE `leaderboard` (
`game_id` int(11) NOT NULL,
`time_entry` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`username` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`score` int(11) NOT NULL,
`percent` tinyint(4) NOT NULL,
`level` tinyint(4) NOT NULL,
`config_file` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`inst_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Table structure for table `remembered_logins`
--
CREATE TABLE `remembered_logins` (
`token` varchar(40) NOT NULL,
`user_id` int(11) NOT NULL,
`expires_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`institution_name` varchar(50) NOT NULL,
`name` varchar(128) NOT NULL,
`email` varchar(128) NOT NULL,
`password` varchar(60) NOT NULL,
`password_reset_token` varchar(40) DEFAULT NULL,
`password_reset_expires_at` datetime DEFAULT NULL,
`activation_token` varchar(40) DEFAULT NULL,
`is_active` tinyint(1) NOT NULL DEFAULT '0',
`is_admin` tinyint(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Indexes for table `leaderboard`
--
ALTER TABLE `leaderboard`
ADD PRIMARY KEY (`game_id`);
--
-- Indexes for table `remembered_logins`
--
ALTER TABLE `remembered_logins`
ADD PRIMARY KEY (`token`),
ADD KEY `user_id` (`user_id`),
ADD KEY `expires_at` (`expires_at`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `email` (`email`),
ADD UNIQUE KEY `institution_name` (`institution_name`),
ADD UNIQUE KEY `password_reset_token` (`password_reset_token`),
ADD UNIQUE KEY `activation_token` (`activation_token`),
ADD KEY `name` (`name`);
--
-- AUTO_INCREMENT for table `leaderboard`
--
ALTER TABLE `leaderboard`
MODIFY `game_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- Constraints for table `remembered_logins`
--
ALTER TABLE `remembered_logins`
ADD CONSTRAINT `remembered_logins_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;