Made some changes to how index pages are made

This commit is contained in:
Leon Mika 2025-02-16 14:06:45 +11:00
parent ba12398d2f
commit 573517565d
14 changed files with 259 additions and 56 deletions

View file

@ -17,6 +17,10 @@ CREATE TYPE page_name_provenance AS ENUM (
'date'
);
CREATE TYPE page_role AS ENUM (
'index'
);
CREATE TABLE users (
id BIGSERIAL NOT NULL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
@ -36,7 +40,7 @@ CREATE TABLE sites (
-- Post role is used to describe a specific kind of post, such as a link.
-- When set, it specifies the layout to use for the page
CREATE TABLE post_roles (
CREATE TABLE post_types (
id BIGSERIAL NOT NULL PRIMARY KEY,
site_id BIGINT NOT NULL,
layout_name TEXT NOT NULL,
@ -48,7 +52,7 @@ CREATE TABLE posts (
id BIGSERIAL NOT NULL PRIMARY KEY,
site_id BIGINT NOT NULL,
title TEXT,
role BIGINT,
post_type_id BIGINT,
body TEXT NOT NULL,
state post_state NOT NULL,
props JSON NOT NULL,
@ -56,7 +60,7 @@ CREATE TABLE posts (
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL,
FOREIGN KEY (role) REFERENCES post_roles (id) ON DELETE CASCADE,
FOREIGN KEY (post_type_id) REFERENCES post_types (id) ON DELETE CASCADE,
FOREIGN KEY (site_id) REFERENCES sites (id) ON DELETE CASCADE
);
@ -77,19 +81,21 @@ CREATE TABLE pages (
name TEXT NOT NULL,
name_provenance page_name_provenance NOT NULL,
title TEXT,
role BIGINT,
post_type_id BIGINT,
body TEXT NOT NULL,
state post_state NOT NULL,
props JSON NOT NULL,
role page_role,
publish_date TIMESTAMP WITH TIME ZONE,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL,
UNIQUE (bundle_id, name),
FOREIGN KEY (site_id) REFERENCES sites (id) ON DELETE CASCADE,
FOREIGN KEY (role) REFERENCES post_roles (id) ON DELETE CASCADE,
FOREIGN KEY (post_type_id) REFERENCES post_types (id) ON DELETE CASCADE,
FOREIGN KEY (bundle_id) REFERENCES sites (id) ON DELETE CASCADE
);
CREATE UNIQUE INDEX page_bundle_id_role ON pages (bundle_id, role) WHERE (role is NOT null);
CREATE TABLE publish_targets (
id BIGSERIAL NOT NULL PRIMARY KEY,