Added post versions; updated db boilerplate
This commit is contained in:
parent
8af3ff6996
commit
b0d7f77983
10 changed files with 211 additions and 34 deletions
|
|
@ -2,9 +2,7 @@
|
|||
drop trigger insert_enforce_version_titles on versions;
|
||||
drop trigger update_enforce_version_titles on versions;
|
||||
drop function enforce_version_titles;
|
||||
drop index sections_shortname_index;
|
||||
|
||||
drop table versions cascade;
|
||||
drop table tags cascade;
|
||||
drop table posts cascade;
|
||||
drop table sections cascade;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Reference in a new issue