Initial open source release
This commit is contained in:
commit
74992e893f
377 changed files with 118084 additions and 0 deletions
16
deploy/migrations/0053_user_top_reactions.up.sql
Normal file
16
deploy/migrations/0053_user_top_reactions.up.sql
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
CREATE TABLE IF NOT EXISTS user_top_reactions (
|
||||
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
reaction_type VARCHAR(16) NOT NULL,
|
||||
reaction_value TEXT NOT NULL,
|
||||
reaction_count INT NOT NULL DEFAULT 0,
|
||||
reaction_date INT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (user_id, reaction_type, reaction_value),
|
||||
CHECK (reaction_type IN ('emoji')),
|
||||
CHECK (reaction_value <> ''),
|
||||
CHECK (reaction_count >= 0)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS user_top_reactions_user_rank_idx
|
||||
ON user_top_reactions (user_id, reaction_count DESC, reaction_date DESC, updated_at DESC, reaction_value ASC);
|
||||
Loading…
Add table
Add a link
Reference in a new issue