-- +goose Up
CREATE TABLE click_logs (
    click_id BIGSERIAL PRIMARY KEY,
    url_id INT NOT NULL REFERENCES urls(url_id) ON DELETE CASCADE,
    clicked_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
    referrer VARCHAR(255),
    user_agent TEXT,
    ip_address VARCHAR(45) -- Accommodates both IPv4 and IPv6
);

-- Index to optimize analytics queries for a specific link
CREATE INDEX idx_click_logs_url_id ON click_logs(url_id);

-- +goose Down
DROP INDEX idx_click_logs_url_id;
DROP TABLE click_logs;