-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
423 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE site_alert_dismiss, site_alert; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CREATE TABLE site_alert ( | ||
id uuid PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(), | ||
created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, | ||
active boolean NOT NULL DEFAULT true, | ||
content text NOT NULL | ||
); | ||
|
||
CREATE INDEX site_alert_lookup_idx ON site_alert (created_at DESC); | ||
|
||
CREATE TABLE site_alert_dismiss ( | ||
site_alert_id uuid NOT NULL REFERENCES site_alert (id) ON DELETE CASCADE, | ||
user_account_id uuid NOT NULL REFERENCES user_account (id) ON DELETE CASCADE, | ||
dismissed_at timestamp with time zone NOT NULL DEFAULT current_timestamp, | ||
PRIMARY KEY (site_alert_id, user_account_id) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
SELECT | ||
id, | ||
created_at, | ||
active, | ||
content | ||
FROM | ||
site_alert | ||
LEFT JOIN site_alert_dismiss ON site_alert_dismiss.site_alert_id = site_alert.id AND site_alert_dismiss.user_account_id = $1 | ||
WHERE | ||
site_alert_dismiss.site_alert_id IS NULL | ||
AND active = true | ||
ORDER BY | ||
created_at DESC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
INSERT INTO | ||
site_alert (content) | ||
VALUES | ||
($1) RETURNING id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
UPDATE | ||
site_alert | ||
SET | ||
active = false | ||
WHERE | ||
id = $1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
INSERT INTO | ||
site_alert_dismiss (site_alert_id, user_account_id) | ||
VALUES | ||
($1, $2) ON CONFLICT DO NOTHING; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SELECT | ||
id, | ||
created_at, | ||
active, | ||
content | ||
FROM | ||
site_alert | ||
ORDER BY | ||
created_at DESC | ||
LIMIT | ||
50; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.