Chatto/chatto/src/main/resources/scheme.sql

375 lines
14 KiB
MySQL
Raw Normal View History

2019-10-04 10:10:26 +00:00
-- -- MySQL dump 10.15 Distrib 10.0.38-MariaDB, for debian-linux-gnu (x86_64)
-- --
-- -- Host: localhost Database: chatto_db
-- -- ------------------------------------------------------
-- -- Server version 10.0.38-MariaDB-0ubuntu0.16.04.1
-- /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-- /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-- /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-- /*!40101 SET NAMES utf8mb4 */;
-- /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
-- /*!40103 SET TIME_ZONE='+00:00' */;
-- /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
-- /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
-- /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-- /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-- --
-- -- Table structure for table `admins`
-- --
-- --DROP TABLE IF EXISTS `admins`;
-- /*!40101 SET @saved_cs_client = @@character_set_client */;
-- /*!40101 SET character_set_client = utf8 */;
-- -- CREATE TABLE IF NOT EXISTS `admins` (
-- -- `admin_id` int(11) NOT NULL AUTO_INCREMENT,
-- -- `user_id` int(11) NOT NULL,
-- -- PRIMARY KEY (`admin_id`),
-- -- UNIQUE KEY `user_id_2` (`user_id`),
-- -- KEY `admin_id` (`admin_id`),
-- -- KEY `user_id` (`user_id`),
-- -- CONSTRAINT `fk_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE
-- -- ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;
-- /*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- -- Table structure for table `chat_messages`
-- --
-- /*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- -- Table structure for table `chatmessage`
-- --
-- --DROP TABLE IF EXISTS `chatmessage`;
-- /*!40101 SET @saved_cs_client = @@character_set_client */;
-- /*!40101 SET character_set_client = utf8 */;
-- CREATE TABLE IF NOT EXISTS `chatmessage` (
-- `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-- `Message` varchar(4000) NOT NULL,
-- `userName` varchar(100) NOT NULL,
-- `MsgTime` varchar(45) NOT NULL,
-- `colorSelected` varchar(45) NOT NULL,
-- PRIMARY KEY (`Id`)
-- ) ENGINE=InnoDB AUTO_INCREMENT=402 DEFAULT CHARSET=latin1;
-- /*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- -- Table structure for table `message_ciphers`
-- --
-- --DROP TABLE IF EXISTS `message_ciphers`;
-- /*!40101 SET @saved_cs_client = @@character_set_client */;
-- /*!40101 SET character_set_client = utf8 */;
-- CREATE TABLE IF NOT EXISTS `message_ciphers` (
-- `id` int(11) NOT NULL AUTO_INCREMENT,
-- `iv` varchar(30) NOT NULL,
-- `v` int(2) NOT NULL,
-- `iterations` int(11) NOT NULL,
-- `key_size` int(11) NOT NULL,
-- `tag_size` int(11) NOT NULL,
-- `mode` varchar(11) NOT NULL,
-- `adata` varchar(11) NOT NULL,
-- `cipher` varchar(11) NOT NULL,
-- `salt` varchar(100) NOT NULL,
-- `cipher_text` varchar(600) NOT NULL,
-- PRIMARY KEY (`id`)
-- ) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8mb4;
-- /*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- -- Table structure for table `roles`
-- --
-- --DROP TABLE IF EXISTS `roles`;
-- /*!40101 SET @saved_cs_client = @@character_set_client */;
-- /*!40101 SET character_set_client = utf8 */;
-- CREATE TABLE IF NOT EXISTS `roles` (
-- `role_id` int(5) NOT NULL,
-- `role_name` varchar(15) NOT NULL,
-- `description` varchar(20) NOT NULL,
-- PRIMARY KEY (`role_id`)
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- /*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- -- Table structure for table `total_messages`
-- --
-- --DROP TABLE IF EXISTS `total_messages`;
-- /*!40101 SET @saved_cs_client = @@character_set_client */;
-- /*!40101 SET character_set_client = utf8 */;
-- CREATE TABLE IF NOT EXISTS `total_messages` (
-- `t_id` int(101) NOT NULL AUTO_INCREMENT,
-- `from_user` int(11) NOT NULL,
-- `to_user` int(11) NOT NULL,
-- `total_messages` int(11) NOT NULL,
-- PRIMARY KEY (`t_id`),
-- UNIQUE KEY `identifier` (`t_id`)
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- /*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- -- Table structure for table `users`
-- --
-- --DROP TABLE IF EXISTS `users`;
-- /*!40101 SET @saved_cs_client = @@character_set_client */;
-- /*!40101 SET character_set_client = utf8 */;
-- CREATE TABLE IF NOT EXISTS `users` (
-- `user_id` int(11) NOT NULL AUTO_INCREMENT,
-- `name` varchar(10) NOT NULL,
-- `password` varchar(80) NOT NULL,
-- `join_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-- PRIMARY KEY (`user_id`),
-- UNIQUE KEY `name` (`name`),
-- KEY `user_id` (`user_id`)
-- ) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4;
-- /*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- -- Table structure for table `users_roles`
-- --
-- --DROP TABLE IF EXISTS `users_roles`;
-- /*!40101 SET @saved_cs_client = @@character_set_client */;
-- /*!40101 SET character_set_client = utf8 */;
-- CREATE TABLE IF NOT EXISTS `users_roles` (
-- `id` int(11) NOT NULL AUTO_INCREMENT,
-- `user_id` int(11) NOT NULL,
-- `role_id` int(11) NOT NULL,
-- PRIMARY KEY (`id`),
-- KEY `user` (`user_id`),
-- KEY `role` (`role_id`),
-- CONSTRAINT `FOREIGN KEY USER IN USERS-ROLES TABLE` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
-- CONSTRAINT `fk_roles_roleAssignments` FOREIGN KEY (`role_id`) REFERENCES `roles` (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE
-- ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4;
-- /*!40101 SET character_set_client = @saved_cs_client */;
-- /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
-- /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
-- /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
-- /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
-- /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
-- /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
-- /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-- /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- -- Dump completed on 2019-10-03 12:37:23
-- --DROP TABLE IF EXISTS `chat_messages`;
-- /*!40101 SET @saved_cs_client = @@character_set_client */;
-- /*!40101 SET character_set_client = utf8 */;
-- CREATE TABLE IF NOT EXISTS `chat_messages` (
-- `m_id` bigint(20) NOT NULL AUTO_INCREMENT,
-- `from_user` int(11) NOT NULL,
-- `to_user` int(11) NOT NULL,
-- `message` int(10) NOT NULL,
-- `message_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-- PRIMARY KEY (`m_id`),
-- UNIQUE KEY `identifier_message_number` (`m_id`),
-- KEY `identifier_message_number_2` (`m_id`),
-- KEY `from_user` (`from_user`,`to_user`),
-- KEY `message` (`message`),
-- KEY `FOREIGN KEY TO USER IN MESSAGES TABLE` (`to_user`),
-- CONSTRAINT `FOREIGN KEY ENC MESSAGE TABLE` FOREIGN KEY (`message`) REFERENCES `message_ciphers` (`id`) ON UPDATE CASCADE,
-- CONSTRAINT `FOREIGN KEY FROM USER IN MESSAGES TABLE` FOREIGN KEY (`from_user`) REFERENCES `users` (`user_id`) ON UPDATE CASCADE,
-- CONSTRAINT `FOREIGN KEY TO USER IN MESSAGES TABLE` FOREIGN KEY (`to_user`) REFERENCES `users` (`user_id`) ON UPDATE CASCADE
-- ) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8mb4;
-- MySQL dump 10.15 Distrib 10.0.38-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: chatto_db
-- ------------------------------------------------------
-- Server version 10.0.38-MariaDB-0ubuntu0.16.04.1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `chat_messages`
--
--DROP TABLE IF EXISTS `chat_messages`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `chatmessage`
--
--DROP TABLE IF EXISTS `chatmessage`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-- CREATE TABLE IF NOT EXISTS `chatmessage` (
-- `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-- `Message` varchar(4000) NOT NULL,
-- `userName` varchar(100) NOT NULL,
-- `MsgTime` varchar(45) NOT NULL,
-- `colorSelected` varchar(45) NOT NULL,
-- PRIMARY KEY (`Id`)
-- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
2019-10-04 10:10:26 +00:00
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `message_ciphers`
--
--DROP TABLE IF EXISTS `message_ciphers`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `message_ciphers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iv` varchar(30) NOT NULL,
`v` int(2) NOT NULL,
`iterations` int(11) NOT NULL,
`key_size` int(11) NOT NULL,
`tag_size` int(11) NOT NULL,
`mode` varchar(11) NOT NULL,
`adata` varchar(11) NOT NULL,
`cipher` varchar(11) NOT NULL,
`salt` varchar(100) NOT NULL,
`cipher_text` varchar(2000) NOT NULL,
2019-10-04 10:10:26 +00:00
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `roles`
--
--DROP TABLE IF EXISTS `roles`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `roles` (
`role_id` int(5) NOT NULL,
`role_name` varchar(15) NOT NULL,
`description` varchar(20) NOT NULL,
PRIMARY KEY (`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `total_messages`
--
--DROP TABLE IF EXISTS `total_messages`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `total_messages` (
`t_id` int(101) NOT NULL AUTO_INCREMENT,
`from_user` int(11) NOT NULL,
`to_user` int(11) NOT NULL,
`total_messages` int(11) NOT NULL,
PRIMARY KEY (`t_id`),
UNIQUE KEY `identifier` (`t_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `users`
--
--DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `users` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(10) NOT NULL,
`password` varchar(80) NOT NULL,
`join_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`user_id`),
UNIQUE KEY `name` (`name`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `users_roles`
--
--DROP TABLE IF EXISTS `users_roles`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE IF NOT EXISTS `users_roles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`role_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `user` (`user_id`),
KEY `role` (`role_id`),
CONSTRAINT `FOREIGN KEY USER IN USERS-ROLES TABLE` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_roles_roleAssignments` FOREIGN KEY (`role_id`) REFERENCES `roles` (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `chat_messages` (
`m_id` bigint(20) NOT NULL AUTO_INCREMENT,
`from_user` int(11) NOT NULL,
`to_user` int(11) NOT NULL,
`message` int(10) NOT NULL,
`message_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`m_id`),
UNIQUE KEY `identifier_message_number` (`m_id`),
KEY `identifier_message_number_2` (`m_id`),
KEY `from_user` (`from_user`,`to_user`),
KEY `message` (`message`),
KEY `FOREIGN KEY TO USER IN MESSAGES TABLE` (`to_user`),
CONSTRAINT `FOREIGN KEY ENC MESSAGE TABLE` FOREIGN KEY (`message`) REFERENCES `message_ciphers` (`id`) ON UPDATE CASCADE,
CONSTRAINT `FOREIGN KEY FROM USER IN MESSAGES TABLE` FOREIGN KEY (`from_user`) REFERENCES `users` (`user_id`) ON UPDATE CASCADE,
CONSTRAINT `FOREIGN KEY TO USER IN MESSAGES TABLE` FOREIGN KEY (`to_user`) REFERENCES `users` (`user_id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2019-10-03 12:37:23
CREATE TABLE IF NOT EXISTS `status` (
`id` int(2) NOT NULL AUTO_INCREMENT,
`name` varchar(15) NOT NULL,
`value` tinyint(1) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `user_sessions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(15) NOT NULL,
`online` tinyint(1) NOT NULL,
`num_sessions` int(11) NOT NULL,
`time_stamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `user_name` (`user_id`),
CONSTRAINT `FOREIGN KEY USER ID` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `tokens` (
`token_id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(15) NOT NULL,
`token_content` varchar(256) NOT NULL,
`role` varchar(15) NOT NULL,
PRIMARY KEY (`token_id`),
UNIQUE KEY `user_name` (`user_name`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4;