-- phpMyAdmin SQL Dump
-- version 5.0.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Jun 14, 2020 at 10:02 PM
-- Server version: 5.7.30-0ubuntu0.18.04.1
-- PHP Version: 7.2.24-0ubuntu0.18.04.6

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!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 */;

--
-- Database: `ThreadR`
--

-- --------------------------------------------------------

--
-- Table structure for table `boards`
--

CREATE TABLE `boards` (
  `board_id` bigint(20) NOT NULL,
  `name_technical` varchar(100) CHARACTER SET ascii COLLATE ascii_bin NOT NULL COMMENT 'url normally defined by name; switched over to name and id when duplicate found, should be base64, just in case',
  `name_user-friendly` varchar(100) CHARACTER SET ascii COLLATE ascii_bin NOT NULL COMMENT 'should be base64 encoded',
  `description` varchar(4096) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL COMMENT 'should be base64 encoded',
  `private` tinyint(1) NOT NULL DEFAULT '0',
  `public_visible` tinyint(1) NOT NULL DEFAULT '0',
  `time_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `time_altered` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- --------------------------------------------------------

--
-- Table structure for table `posts`
--

CREATE TABLE `posts` (
  `post_id` bigint(48) NOT NULL,
  `board_id` bigint(20) NOT NULL,
  `user_id` int(11) NOT NULL,
  `time_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `time_altered` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `content` text,
  `attachment_hash` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'length determined by max file name size on ext4',
  `attachment_file-name` varchar(255) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL COMMENT 'should be base64 encoded, length determined by max file name size on ext4',
  `title` varchar(100) CHARACTER SET ascii COLLATE ascii_bin NOT NULL COMMENT 'should be base64 encoded'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- --------------------------------------------------------

--
-- Table structure for table `profiles`
--

CREATE TABLE `profiles` (
  `user_id` int(11) NOT NULL,
  `email` varchar(200) CHARACTER SET ascii COLLATE ascii_bin NOT NULL COMMENT 'should be base64 encoded',
  `avatar_hash` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `real_name` varchar(100) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL COMMENT 'should be base64 encoded',
  `about` varchar(8192) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL COMMENT 'the user''s bio (or whatever), should be base64 encoded',
  `website` varchar(4096) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL COMMENT 'should be base64 encoded',
  `status` varchar(512) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL COMMENT 'should be base64 encoded',
  `time_altered` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `user_id` int(11) NOT NULL COMMENT 'This is never to be given to the user. Session management will happen in-house.',
  `name` varchar(40) CHARACTER SET ascii COLLATE ascii_bin NOT NULL COMMENT 'should be base64 encoded',
  `time_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `time_altered` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'This is only for changing core user information. Used for checks like "Did X update their password?"',
  `verified` tinyint(1) NOT NULL DEFAULT '0',
  `authentication_algorithm` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  `authentication_salt` varchar(24) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  `authentication_string` varchar(224) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT 'This should be an impossible situation.' COMMENT 'Default value cause Yeeee!'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `boards`
--
ALTER TABLE `boards`
  ADD PRIMARY KEY (`board_id`);

--
-- Indexes for table `posts`
--
ALTER TABLE `posts`
  ADD PRIMARY KEY (`post_id`);

--
-- Indexes for table `profiles`
--
ALTER TABLE `profiles`
  ADD PRIMARY KEY (`user_id`),
  ADD UNIQUE KEY `EMAIL` (`email`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`user_id`),
  ADD UNIQUE KEY `USERNAME` (`name`),
  ADD UNIQUE KEY `id` (`user_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `boards`
--
ALTER TABLE `boards`
  MODIFY `board_id` bigint(20) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'This is never to be given to the user. Session management will happen in-house.';
COMMIT;

/*!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 */;
