-
Notifications
You must be signed in to change notification settings - Fork 4
/
db-init.sql
32 lines (29 loc) · 1.19 KB
/
db-init.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
CREATE DATABASE IF NOT EXISTS `demoDb` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
USE `demoDb`;
CREATE TABLE IF NOT EXISTS `users` (
`RowId` int(11) NOT NULL AUTO_INCREMENT,
`UserId` char(36) NOT NULL,
`Email` varchar(128) NOT NULL,
`PassHash` varchar(128) NOT NULL,
`Confirm` char(32) DEFAULT NULL,
`Active` tinyint(1) NOT NULL DEFAULT '1', -- Default to 0 if you want to require email confirmation
`Role` enum('user','admin') NOT NULL DEFAULT 'user',
`CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`UserId`),
UNIQUE KEY `RowId_UNIQUE` (`RowId`),
UNIQUE KEY `UserId_UNIQUE` (`UserId`),
UNIQUE KEY `Email_UNIQUE` (`Email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `sessions` (
`SessionId` int(11) NOT NULL AUTO_INCREMENT,
`SessionKey` char(32) NOT NULL,
`UserId` char(36) NOT NULL,
`Expires` TIMESTAMP NOT NULL,
`Active` tinyint(1) NOT NULL DEFAULT '1',
`Created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`LastUsed` TIMESTAMP NOT NULL,
`UserAgent` text,
PRIMARY KEY (`SessionId`),
UNIQUE KEY `SessionId_UNIQUE` (`SessionId`),
UNIQUE KEY `SessionKey_UNIQUE` (`SessionKey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;