--
-- Create schema
--
CREATE DATABASE IF NOT EXISTS myapp;
USE myapp;

--
-- Definition of table `user`
--
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `login` varchar(128) NOT NULL,
  `password_hash` char(40) DEFAULT NULL,
  `full_name` varchar(128) NOT NULL,
  `is_admin` tinyint(3) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `LOGIN` (`login`,`password_hash`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
INSERT INTO `user` (`id`,`login`,`full_name`,`is_admin`) VALUES 
 (0,'admin','Administrator',1);
/*!40000 ALTER TABLE `user` ENABLE KEYS */;

--
-- Definition of table `customer`
--
DROP TABLE IF EXISTS `customer`;
CREATE TABLE `customer` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `email` varchar(128) NOT NULL,
  `login` varchar(128) NOT NULL,
  `password_hash` char(40) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `first_name` varchar(90) DEFAULT NULL,
  `last_name` varchar(90) DEFAULT NULL,
  `email_validation_code` char(40) DEFAULT NULL,
  `is_password_temporary` tinyint(3) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `CUSTOMER_LOGIN_INDEX` (`login`),
  KEY `CUSTOMER_EMAIL_INDEX` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

