-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adding new migration for notification and updating ERD
- Loading branch information
1 parent
657a43f
commit 42307a3
Showing
2 changed files
with
44 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
CREATE TYPE notification_states | ||
AS ENUM ('queued', 'processing', 'published', 'not-subscribed', 'wrong-scope', 'rate-limited'); | ||
|
||
CREATE TABLE notification ( | ||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(), | ||
type VARCHAR(255) NOT NULL, | ||
title VARCHAR(255) NOT NULL, | ||
body VARCHAR(255) NOT NULL, | ||
icon VARCHAR(255) NOT NULL, | ||
url VARCHAR(255) NOT NULL | ||
); | ||
|
||
CREATE TABLE notification_status ( | ||
PRIMARY KEY (notification_id, subscriber_id), | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(), | ||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(), | ||
state notification_states NOT NULL, | ||
notification_id UUID NOT NULL REFERENCES notification (id) ON DELETE CASCADE, | ||
subscriber_id UUID NOT NULL REFERENCES subscriber (id) ON DELETE CASCADE | ||
); | ||
CREATE INDEX notification_delivery_subscriber_id ON notification_status (subscriber_id); | ||
CREATE INDEX notification_delivery_notification_id ON notification_status (notification_id); | ||
CREATE INDEX notification_delivery_state ON notification_status (state); | ||
CREATE INDEX notification_delivery_created_and_updated ON notification_status (created_at, updated_at); |
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