Started working on pages

This commit is contained in:
Leon Mika 2025-02-16 11:43:22 +11:00
parent e2f159e980
commit ba12398d2f
30 changed files with 1391 additions and 145 deletions

View file

@ -11,6 +11,12 @@ CREATE TYPE target_type AS ENUM (
'netlify'
);
CREATE TYPE page_name_provenance AS ENUM (
'user',
'title',
'date'
);
CREATE TABLE users (
id BIGSERIAL NOT NULL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
@ -28,19 +34,63 @@ CREATE TABLE sites (
FOREIGN KEY (owner_user_id) REFERENCES users (id)
);
CREATE TABLE posts (
id BIGSERIAL NOT NULL PRIMARY KEY,
site_id BIGINT NOT NULL,
title TEXT,
body TEXT NOT NULL,
state post_state NOT NULL,
props JSON NOT NULL,
post_date TIMESTAMP WITH TIME ZONE,
created_at TIMESTAMP NOT NULL,
-- 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 (
id BIGSERIAL NOT NULL PRIMARY KEY,
site_id BIGINT NOT NULL,
layout_name TEXT NOT NULL,
FOREIGN KEY (site_id) REFERENCES sites (id) ON DELETE CASCADE
);
CREATE TABLE posts (
id BIGSERIAL NOT NULL PRIMARY KEY,
site_id BIGINT NOT NULL,
title TEXT,
role BIGINT,
body TEXT NOT NULL,
state post_state NOT NULL,
props JSON NOT NULL,
publish_date TIMESTAMP WITH TIME ZONE,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL,
FOREIGN KEY (role) REFERENCES post_roles (id) ON DELETE CASCADE,
FOREIGN KEY (site_id) REFERENCES sites (id) ON DELETE CASCADE
);
CREATE TABLE bundles (
id BIGSERIAL NOT NULL PRIMARY KEY,
site_id BIGINT NOT NULL,
name TEXT NOT NULL,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL,
FOREIGN KEY (site_id) REFERENCES sites (id) ON DELETE CASCADE
);
CREATE TABLE pages (
id BIGSERIAL NOT NULL PRIMARY KEY,
site_id BIGINT NOT NULL,
bundle_id BIGINT NOT NULL,
name TEXT NOT NULL,
name_provenance page_name_provenance NOT NULL,
title TEXT,
role BIGINT,
body TEXT NOT NULL,
state post_state NOT NULL,
props JSON NOT NULL,
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 (bundle_id) REFERENCES sites (id) ON DELETE CASCADE
);
CREATE TABLE publish_targets (
id BIGSERIAL NOT NULL PRIMARY KEY,
site_id BIGINT NOT NULL,