-
Notifications
You must be signed in to change notification settings - Fork 6
/
db.sql
35 lines (32 loc) · 1022 Bytes
/
db.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
--CREATE DATABASE `members`;
--USE `members`;
CREATE TABLE `Payments` (
`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
`email` char(64) NOT NULL,
`submitted` datetime NOT NULL,
`amount` int(11) NOT NULL,
`verified` tinyint(1) DEFAULT NULL
);
CREATE INDEX `IDX_Payments_EMAIL` ON `Payments`(`email`);
CREATE TABLE `Users` (
`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
`email` char(64) NOT NULL,
`password` char(32) NULL,
`salt` char(32) NULL,
`last_update` timestamp DEFAULT CURRENT_TIMESTAMP,
`paid_verified` date DEFAULT NULL,
`paid` date DEFAULT NULL,
`since` date NOT NULL,
`count` int(11) NOT NULL DEFAULT 0,
`mac` char(40) DEFAULT NULL
);
CREATE UNIQUE INDEX `IDX_Users_EMAIL` ON `Users`(`email`);
CREATE UNIQUE INDEX `IDX_Users_PASSWORD` ON `Users`(`password`);
CREATE UNIQUE INDEX `IDX_Users_MAC` ON `Users`(`mac`);
CREATE TRIGGER [UpdateLastTime]
AFTER UPDATE
ON Users
FOR EACH ROW
BEGIN
UPDATE Users SET last_update = CURRENT_TIMESTAMP WHERE id = old.id;
END