Implement quotes.

This commit is contained in:
2025-08-28 15:42:53 +10:00
parent 45e6ed4e29
commit d9fa5c4683
9 changed files with 496 additions and 28 deletions

View File

@@ -8,6 +8,7 @@ CREATE TABLE quotes(
communityid INTEGER NOT NULL REFERENCES communities(communityid) ON DELETE CASCADE ON UPDATE CASCADE,
content TEXT NOT NULL,
created_by INTEGER REFERENCES user_profiles(profileid) ON UPDATE CASCADE ON DELETE NO ACTION,
deleted_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
_timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
@@ -19,7 +20,8 @@ CREATE VIEW
AS
SELECT
*,
row_number() + 1 OVER (PARITION BY communityid ORDER BY created_at ASC)
(deleted_at is not NULL) AS is_deleted,
(row_number() OVER (PARTITION BY communityid ORDER BY created_at ASC)) as quotelabel
FROM
quotes
ORDER BY (communityid, created_at);