Added post versions; updated db boilerplate

This commit is contained in:
Jef Roosens 2021-12-26 17:46:17 +01:00
parent 8af3ff6996
commit b0d7f77983
Signed by: Jef Roosens
GPG key ID: 955C0660072F691F
10 changed files with 211 additions and 34 deletions

View file

@ -6,17 +6,17 @@ create table sections (
-- Name to use when routing (this just makes for prettier URLs)
shortname varchar(32) UNIQUE NOT NULL,
-- Optional description of the section
description text,
description text NOT NULL DEFAULT '',
-- Wether to show the section in the default list on the homepage
is_default boolean NOT NULL DEFAULT false,
-- Wether the posts should contain titles or not
has_titles boolean NOT NULL DEFAULT true,
-- Wether posts in this section should be shown publicly
is_private boolean NOT NULL DEFAULT false
is_private boolean NOT NULL DEFAULT false,
-- Wether the section is archived
is_archived boolean NOT NULL DEFAULT false
);
create index sections_shortname_index on sections(shortname);
create table posts (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
@ -51,13 +51,6 @@ create table versions (
CONSTRAINT no_null_published_date CHECK (is_draft OR publish_date IS NOT NULL)
);
create table tags (
post_id uuid NOT NULL REFERENCES posts(id) ON DELETE CASCADE,
value varchar(64) NOT NULL,
PRIMARY KEY (post_id, value)
);
create function enforce_version_titles() returns trigger as $$
begin
-- Draft versions shouldn't be evaluated.