mirror of https://github.com/synctv-org/synctv
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
637 B
SQL
14 lines
637 B
SQL
CREATE TABLE IF NOT EXISTS user_blocks (
|
|
blocker_user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
blocked_user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (blocker_user_id, blocked_user_id),
|
|
CONSTRAINT user_blocks_no_self_block CHECK (blocker_user_id <> blocked_user_id)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_user_blocks_blocker_created
|
|
ON user_blocks(blocker_user_id, created_at DESC, blocked_user_id DESC);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_user_blocks_blocked
|
|
ON user_blocks(blocked_user_id, blocker_user_id);
|