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.
synctv/migrations/20260426035_create_room_mem...

20 lines
798 B
SQL

CREATE TABLE IF NOT EXISTS room_member_kick_cooldowns (
id BIGSERIAL PRIMARY KEY,
room_id BIGINT NOT NULL REFERENCES rooms(id) ON DELETE CASCADE,
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
kicked_by BIGINT,
starts_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
ends_at TIMESTAMPTZ NOT NULL,
reason TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_room_member_kick_cooldowns_room
ON room_member_kick_cooldowns(room_id, starts_at DESC);
CREATE INDEX IF NOT EXISTS idx_room_member_kick_cooldowns_user
ON room_member_kick_cooldowns(user_id, starts_at DESC);
CREATE INDEX IF NOT EXISTS idx_room_member_kick_cooldowns_active
ON room_member_kick_cooldowns(room_id, user_id, ends_at);