update db schema
This commit is contained in:
parent
7c8f817310
commit
13ec8cbd74
1 changed files with 22 additions and 62 deletions
|
@ -3,9 +3,9 @@
|
|||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: localhost
|
||||
-- Generation Time: May 12, 2024 at 03:59 PM
|
||||
-- Server version: 11.3.2-MariaDB
|
||||
-- PHP Version: 8.3.6
|
||||
-- Generation Time: Jul 20, 2024 at 02:33 PM
|
||||
-- Server version: 11.4.2-MariaDB
|
||||
-- PHP Version: 8.3.9
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
|
@ -20,8 +20,6 @@ SET time_zone = "+00:00";
|
|||
--
|
||||
-- Database: `zdenekborovec`
|
||||
--
|
||||
CREATE DATABASE IF NOT EXISTS `zdenekborovec` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
USE `zdenekborovec`;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
|
@ -29,13 +27,15 @@ USE `zdenekborovec`;
|
|||
-- Table structure for table `blogposts`
|
||||
--
|
||||
|
||||
CREATE TABLE `blogposts` (
|
||||
CREATE TABLE IF NOT EXISTS `blogposts` (
|
||||
`blogpost_id` uuid NOT NULL DEFAULT uuid() COMMENT 'uuid of the blogpost',
|
||||
`readable_address` varchar(64) DEFAULT NULL COMMENT 'Human-readable addressing alternative for an article. For example, blogpost with readable_address = "example" can be accessed by article.php?address=example.',
|
||||
`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 'Datetime at which the article was posted.',
|
||||
`date_edited` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'Timestamp at the lasted edit.'
|
||||
`date_edited` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'Timestamp at the lasted edit.',
|
||||
PRIMARY KEY (`blogpost_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
@ -44,13 +44,14 @@ CREATE TABLE `blogposts` (
|
|||
-- Table structure for table `blogpost_comments`
|
||||
--
|
||||
|
||||
CREATE TABLE `blogpost_comments` (
|
||||
CREATE TABLE IF NOT EXISTS `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.'
|
||||
`content` mediumtext NOT NULL COMMENT 'Content of the comment. Stored as markdown.',
|
||||
PRIMARY KEY (`comment_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Comments on blogposts.';
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
@ -59,9 +60,11 @@ CREATE TABLE `blogpost_comments` (
|
|||
-- Table structure for table `blogpost_has_tag`
|
||||
--
|
||||
|
||||
CREATE TABLE `blogpost_has_tag` (
|
||||
CREATE TABLE IF NOT EXISTS `blogpost_has_tag` (
|
||||
`blogpost_id` uuid NOT NULL,
|
||||
`tag_id` int(11) NOT NULL
|
||||
`tag_id` int(11) NOT NULL,
|
||||
KEY `blogpost_id` (`blogpost_id`),
|
||||
KEY `tag_id` (`tag_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
@ -70,10 +73,11 @@ CREATE TABLE `blogpost_has_tag` (
|
|||
-- Table structure for table `blogpost_tags`
|
||||
--
|
||||
|
||||
CREATE TABLE `blogpost_tags` (
|
||||
`tag_id` int(11) NOT NULL COMMENT 'ID of the tag, primary key.',
|
||||
CREATE TABLE IF NOT EXISTS `blogpost_tags` (
|
||||
`tag_id` int(11) NOT NULL AUTO_INCREMENT 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.'
|
||||
`color` varchar(32) NOT NULL COMMENT 'CSS color string, will be displayed.',
|
||||
PRIMARY KEY (`tag_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Tags that can be used to tag and filter blogposts.';
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
@ -82,60 +86,16 @@ CREATE TABLE `blogpost_tags` (
|
|||
-- Table structure for table `users`
|
||||
--
|
||||
|
||||
CREATE TABLE `users` (
|
||||
CREATE TABLE IF NOT EXISTS `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'
|
||||
`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`)
|
||||
) 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
|
||||
--
|
||||
|
|
Loading…
Reference in a new issue