153 lines
5 KiB
MySQL
153 lines
5 KiB
MySQL
|
-- phpMyAdmin SQL Dump
|
||
|
-- version 5.2.1
|
||
|
-- https://www.phpmyadmin.net/
|
||
|
--
|
||
|
-- Host: localhost
|
||
|
-- Generation Time: May 06, 2024 at 07:34 PM
|
||
|
-- Server version: 11.3.2-MariaDB
|
||
|
-- PHP Version: 8.3.6
|
||
|
|
||
|
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||
|
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: `zdenekborovec`
|
||
|
--
|
||
|
CREATE DATABASE IF NOT EXISTS `zdenekborovec` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||
|
USE `zdenekborovec`;
|
||
|
|
||
|
-- --------------------------------------------------------
|
||
|
|
||
|
--
|
||
|
-- Table structure for table `blogposts`
|
||
|
--
|
||
|
|
||
|
CREATE TABLE `blogposts` (
|
||
|
`blogpost_id` uuid NOT NULL DEFAULT uuid() COMMENT 'uuid of the blogpost',
|
||
|
`title` varchar(64) DEFAULT NULL COMMENT 'title of the blogpost',
|
||
|
`abstract` varchar(512) DEFAULT NULL COMMENT 'short version of the blogpost to be displayed as preview, usually the first paragraph of the real article.',
|
||
|
`content` text DEFAULT NULL COMMENT 'html for the article',
|
||
|
`date_posted` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'Datetimee at which the article was posted.'
|
||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||
|
|
||
|
-- --------------------------------------------------------
|
||
|
|
||
|
--
|
||
|
-- Table structure for table `blogpost_comments`
|
||
|
--
|
||
|
|
||
|
CREATE TABLE `blogpost_comments` (
|
||
|
`comment_id` uuid NOT NULL DEFAULT uuid() COMMENT 'ID of the comment, PK.',
|
||
|
`parent_id` uuid DEFAULT NULL COMMENT 'If this is a response to a comment, this is the id of that parent comment.',
|
||
|
`blogpost_id` uuid NOT NULL COMMENT 'ID of the blogpost this comment is under.',
|
||
|
`poster_id` uuid DEFAULT NULL COMMENT ' ID of the user who posted this comment. ',
|
||
|
`timestamp` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Timestamp when the comment was posted.',
|
||
|
`content` mediumtext NOT NULL COMMENT 'Content of the comment. Stored as markdown.'
|
||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Comments on blogposts.';
|
||
|
|
||
|
-- --------------------------------------------------------
|
||
|
|
||
|
--
|
||
|
-- Table structure for table `blogpost_has_tag`
|
||
|
--
|
||
|
|
||
|
CREATE TABLE `blogpost_has_tag` (
|
||
|
`blogpost_id` uuid NOT NULL,
|
||
|
`tag_id` int(11) NOT NULL
|
||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||
|
|
||
|
-- --------------------------------------------------------
|
||
|
|
||
|
--
|
||
|
-- Table structure for table `blogpost_tags`
|
||
|
--
|
||
|
|
||
|
CREATE TABLE `blogpost_tags` (
|
||
|
`tag_id` int(11) NOT NULL COMMENT 'ID of the tag, primary key.',
|
||
|
`name` varchar(32) NOT NULL COMMENT 'Name of the tag, will be displayed.',
|
||
|
`color` varchar(32) NOT NULL COMMENT 'CSS color string, will be displayed.'
|
||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Tags that can be used to tag and filter blogposts.';
|
||
|
|
||
|
-- --------------------------------------------------------
|
||
|
|
||
|
--
|
||
|
-- Table structure for table `users`
|
||
|
--
|
||
|
|
||
|
CREATE TABLE `users` (
|
||
|
`user_id` uuid NOT NULL DEFAULT uuid() COMMENT 'UUID of the user. Primary key.',
|
||
|
`username` varchar(64) NOT NULL COMMENT 'Display name of the user.',
|
||
|
`password` varchar(255) NOT NULL COMMENT 'password encrypted by password_hash().',
|
||
|
`created_at` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'Timestamp at account creation.',
|
||
|
`permissions` bit(8) NOT NULL DEFAULT b'0' COMMENT 'Permission mask for the user. Rules (from left to right):\r\n0: Can post blogposts.\r\n1: reserved\r\n2: reserved\r\n3: reserved\r\n4: reserved\r\n5: reserved\r\n6: reserved\r\n7: reserved'
|
||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||
|
|
||
|
--
|
||
|
-- Indexes for dumped tables
|
||
|
--
|
||
|
|
||
|
--
|
||
|
-- Indexes for table `blogposts`
|
||
|
--
|
||
|
ALTER TABLE `blogposts`
|
||
|
ADD PRIMARY KEY (`blogpost_id`);
|
||
|
|
||
|
--
|
||
|
-- Indexes for table `blogpost_comments`
|
||
|
--
|
||
|
ALTER TABLE `blogpost_comments`
|
||
|
ADD PRIMARY KEY (`comment_id`);
|
||
|
|
||
|
--
|
||
|
-- Indexes for table `blogpost_has_tag`
|
||
|
--
|
||
|
ALTER TABLE `blogpost_has_tag`
|
||
|
ADD KEY `blogpost_id` (`blogpost_id`),
|
||
|
ADD KEY `tag_id` (`tag_id`);
|
||
|
|
||
|
--
|
||
|
-- Indexes for table `blogpost_tags`
|
||
|
--
|
||
|
ALTER TABLE `blogpost_tags`
|
||
|
ADD PRIMARY KEY (`tag_id`);
|
||
|
|
||
|
--
|
||
|
-- Indexes for table `users`
|
||
|
--
|
||
|
ALTER TABLE `users`
|
||
|
ADD PRIMARY KEY (`user_id`),
|
||
|
ADD UNIQUE KEY `username` (`username`);
|
||
|
|
||
|
--
|
||
|
-- AUTO_INCREMENT for dumped tables
|
||
|
--
|
||
|
|
||
|
--
|
||
|
-- AUTO_INCREMENT for table `blogpost_tags`
|
||
|
--
|
||
|
ALTER TABLE `blogpost_tags`
|
||
|
MODIFY `tag_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID of the tag, primary key.';
|
||
|
|
||
|
--
|
||
|
-- Constraints for dumped tables
|
||
|
--
|
||
|
|
||
|
--
|
||
|
-- Constraints for table `blogpost_has_tag`
|
||
|
--
|
||
|
ALTER TABLE `blogpost_has_tag`
|
||
|
ADD CONSTRAINT `blogpost_has_tag_ibfk_1` FOREIGN KEY (`blogpost_id`) REFERENCES `blogposts` (`blogpost_id`),
|
||
|
ADD CONSTRAINT `blogpost_has_tag_ibfk_2` FOREIGN KEY (`tag_id`) REFERENCES `blogpost_tags` (`tag_id`);
|
||
|
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 */;
|