CREATE TABLE user_follows (
                              id BIGINT PRIMARY KEY,
                              follower_id BIGINT NOT NULL REFERENCES users(id),
                              followee_id BIGINT NOT NULL REFERENCES users(id),
                              created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),

                              UNIQUE(follower_id, followee_id),
                              CONSTRAINT chk_no_self_follow CHECK (follower_id != followee_id)
    );

CREATE INDEX idx_follows_follower ON user_follows(follower_id);
CREATE INDEX idx_follows_followee ON user_follows(followee_id);