29 lines
1.4 KiB
SQL
29 lines
1.4 KiB
SQL
CREATE TABLE IF NOT EXISTS user_mentions (
|
|
-- Unique identifier for each record. Auto-incremented to ensure uniqueness.
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
|
|
-- The unique identifier of the comment from the r/Drama platform. Not unique in this table
|
|
-- because a single comment can mention multiple users.
|
|
rdrama_comment_id TEXT NOT NULL,
|
|
|
|
-- The mentioned Reddit username in a standardized format (e.g., u/username). Lowercased
|
|
-- to ensure consistency and prevent duplicate entries due to case differences.
|
|
username TEXT NOT NULL,
|
|
|
|
-- The content of the message sent to the mentioned user, if any. Allows tracking
|
|
-- of what communication has been made, useful for audit purposes or resending messages.
|
|
message TEXT,
|
|
|
|
-- Timestamp when the mention was processed and, if applicable, when a message was sent.
|
|
-- Defaults to the current timestamp at the time of record creation.
|
|
sent_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
-- Enforces uniqueness for each comment-username pair to prevent processing and notifying
|
|
-- the same user mention in the same comment more than once.
|
|
CONSTRAINT unique_comment_user UNIQUE (rdrama_comment_id, username)
|
|
);
|
|
|
|
-- Consider adding indexes based on query patterns for improved performance, such as:
|
|
-- CREATE INDEX idx_username ON user_mentions(username);
|
|
-- CREATE INDEX idx_rdrama_comment_id ON user_mentions(rdrama_comment_id);
|