CREATE DATABASE IF NOT EXISTS `Auth`;
USE `Auth`;

-- Account Section

CREATE TABLE IF NOT EXISTS `Account` (
  `ID` int NOT NULL AUTO_INCREMENT,
  `UserName` varchar(60) NOT NULL,
  `Email` varchar(255) NOT NULL,
  `EmailVerified` boolean DEFAULT 0,
  `PasswordHash` char(60) DEFAULT NULL,
  `FailedPasswordLock` boolean DEFAULT 0,
  `PasswordAttempts` int(11) DEFAULT NULL,
  `CurrentPasswordAttempts` int(11) DEFAULT NULL,
  `Role` varchar(45) DEFAULT NULL,
  `EmailToken` varchar(45) DEFAULT NULL,
  `EmailTokenCreation` datetime,
  `PasswordToken` varchar(45) DEFAULT NULL,
  `PasswordTokenCreation` datetime,
  `DataServer` varchar(200) DEFAULT NULL,
  UNIQUE(`Email`),
  UNIQUE(`UserName`),
  PRIMARY KEY (`ID`)
) AUTO_INCREMENT=1;

-- Default Account

INSERT INTO Account (
  ID,
  UserName,
  Email,
  EmailVerified,
  PasswordHash,
  FailedPasswordLock,
  PasswordAttempts,
  CurrentPasswordAttempts,
  Role,
  EmailToken,
  DataServer
) VALUES (
  1,
  'admin',
  'admin@mistox.com',
  1,
  '$2a$11$0UeWLLqTXe3FG161QVuI0OQJ9rulspUpMG581DI6KSzDXBbFKd00S',
  0,
  5,
  0,
  'Admin',
  '',
  ''
);