2024-05-06 21:36:30 +02:00
-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost
2024-08-22 01:23:38 +02:00
-- Generation Time: Aug 21, 2024 at 11:22 PM
2024-07-20 16:35:59 +02:00
-- Server version: 11.4.2-MariaDB
2024-08-22 01:23:38 +02:00
-- PHP Version: 8.3.10
2024-05-06 21:36:30 +02:00
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`
--
-- --------------------------------------------------------
--
-- Table structure for table `blogposts`
--
2024-07-20 16:35:59 +02:00
CREATE TABLE IF NOT EXISTS ` blogposts ` (
2024-05-06 21:36:30 +02:00
` blogpost_id ` uuid NOT NULL DEFAULT uuid ( ) COMMENT ' uuid of the blogpost ' ,
2024-08-22 01:23:38 +02:00
` readable_address ` varchar ( 64 ) NOT NULL COMMENT ' Human-readable addressing alternative for an article. For example, blogpost with readable_address = "example" can be accessed by blog/article/example. ' ,
2024-05-06 21:36:30 +02:00
` 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 ' ,
2024-05-12 18:34:33 +02:00
` date_posted ` datetime NOT NULL DEFAULT current_timestamp ( ) COMMENT ' Datetime at which the article was posted. ' ,
2024-07-20 16:35:59 +02:00
` date_edited ` datetime NOT NULL DEFAULT current_timestamp ( ) COMMENT ' Timestamp at the lasted edit. ' ,
PRIMARY KEY ( ` blogpost_id ` )
2024-05-06 21:36:30 +02:00
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci ;
-- --------------------------------------------------------
--
-- Table structure for table `blogpost_comments`
--
2024-07-20 16:35:59 +02:00
CREATE TABLE IF NOT EXISTS ` blogpost_comments ` (
2024-05-06 21:36:30 +02:00
` 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. ' ,
2024-07-20 16:35:59 +02:00
` content ` mediumtext NOT NULL COMMENT ' Content of the comment. Stored as markdown. ' ,
PRIMARY KEY ( ` comment_id ` )
2024-05-06 21:36:30 +02:00
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = ' Comments on blogposts. ' ;
-- --------------------------------------------------------
--
-- Table structure for table `blogpost_has_tag`
--
2024-07-20 16:35:59 +02:00
CREATE TABLE IF NOT EXISTS ` blogpost_has_tag ` (
2024-05-06 21:36:30 +02:00
` blogpost_id ` uuid NOT NULL ,
2024-07-20 16:35:59 +02:00
` tag_id ` int ( 11 ) NOT NULL ,
KEY ` blogpost_id ` ( ` blogpost_id ` ) ,
KEY ` tag_id ` ( ` tag_id ` )
2024-05-06 21:36:30 +02:00
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci ;
-- --------------------------------------------------------
--
-- Table structure for table `blogpost_tags`
--
2024-07-20 16:35:59 +02:00
CREATE TABLE IF NOT EXISTS ` blogpost_tags ` (
` tag_id ` int ( 11 ) NOT NULL AUTO_INCREMENT COMMENT ' ID of the tag, primary key. ' ,
2024-05-06 21:36:30 +02:00
` name ` varchar ( 32 ) NOT NULL COMMENT ' Name of the tag, will be displayed. ' ,
2024-07-20 16:35:59 +02:00
` color ` varchar ( 32 ) NOT NULL COMMENT ' CSS color string, will be displayed. ' ,
PRIMARY KEY ( ` tag_id ` )
2024-05-06 21:36:30 +02:00
) 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`
--
2024-07-20 16:35:59 +02:00
CREATE TABLE IF NOT EXISTS ` users ` (
2024-05-06 21:36:30 +02:00
` 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. ' ,
2024-07-20 16:35:59 +02:00
` 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 ' ,
PRIMARY KEY ( ` user_id ` ) ,
UNIQUE KEY ` username ` ( ` username ` )
2024-05-06 21:36:30 +02:00
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci ;
--
-- 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 */ ;