CREATE TABLE link_clicks (
    id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    code VARCHAR(32) NOT NULL,
    activity_id BIGINT,
    inviter_user_id BIGINT,
    ip VARCHAR(64),
    user_agent VARCHAR(512),
    referer VARCHAR(1024),
    created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_link_clicks_code ON link_clicks(code);
CREATE INDEX idx_link_clicks_activity ON link_clicks(activity_id);

