-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(db): add notification inbox tables
- Added `notifications` table to store notification messages. - Added `readed_notifications` table to track which notifications have been read by users.
- Loading branch information
Showing
2 changed files
with
21 additions
and
0 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 @@ | ||
-- Add down migration script here |
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,20 @@ | ||
CREATE TABLE notifications ( | ||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
|
||
created_at TIMESTAMP NOT NULL DEFAULT(DATETIME('now')), | ||
updated_at TIMESTAMP NOT NULL DEFAULT(DATETIME('now')), | ||
|
||
-- enum of ADMIN, ALL_USERS | ||
kind: TEXT NOT NULL, | ||
|
||
message: TEXT NOT NULL, | ||
) | ||
|
||
CREATE TABLE readed_notifications ( | ||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
user_id INTEGER NOT NULL, | ||
notification_id INTEGER NOT NULL, | ||
|
||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, | ||
FOREIGN KEY (notification_id) REFERENCES notifications(id) ON DELETE CASCADE, | ||
) |