Implement quotes.
This commit is contained in:
@@ -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);
|
||||
Reference in New Issue
Block a user