Skip to content

Commit

Permalink
通知に関するテーブルのCREATE文を追加した。
Browse files Browse the repository at this point in the history
  • Loading branch information
eigoninaritai-naokichi committed May 15, 2024
1 parent ec13ee5 commit 736f602
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE notification_types (
id SERIAL PRIMARY KEY,
type_name VARCHAR(255) NOT NULL UNIQUE
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE notifications (
id BIGSERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(id),
action_user_id INTEGER NOT NULL REFERENCES users(id),
notification_type_id INTEGER NOT NULL REFERENCES notification_types(id),
related_post_id BIGINT NOT NULL REFERENCES posts(id),
related_reply_id BIGINT NULL REFERENCES replies(id),
action_target_reply_id BIGINT NULL REFERENCES replies(id),
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX idx_user_id_on_notifications ON notifications(user_id);
CREATE INDEX idx_action_user_id_on_notifications ON notifications(action_user_id);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE user_notification_statuses (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(id),
is_read BOOLEAN NOT NULL DEFAULT FALSE
);

CREATE INDEX idx_user_id_on_user_notification_statuses ON user_notification_statuses(user_id);
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# 通知テーブル
* ID(主キー)
* ユーザーID(外部キー、NULL不可)
* アクションユーザーID(外部キー、NULL不可)
* 通知タイプID(外部キー、NULL不可)
* 関連投稿ID(外部キー、NULL不可)
* 関連リプライID(外部キー、NULL不可)
* 関連リプライID(外部キー、NULL可)
* アクション対象リプライID(外部キー、NULL可)
* 通知日時
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ユーザー通知ステータス
* ID(主キー)
* ユーザーID(外部キー、NULL不可)
* 既読したかどうか(BOOL、NULL不可)

0 comments on commit 736f602

Please sign in to comment.