CREATE TABLE IF NOT EXISTS robertseares_page_loads (
    id BIGSERIAL PRIMARY KEY,
    path TEXT NOT NULL,
    locale TEXT,
    referrer TEXT,
    user_agent TEXT,
    viewport JSONB NOT NULL DEFAULT '{}'::jsonb,
    metadata JSONB NOT NULL DEFAULT '{}'::jsonb,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE INDEX IF NOT EXISTS robertseares_page_loads_created_at_idx
    ON robertseares_page_loads (created_at DESC);

CREATE INDEX IF NOT EXISTS robertseares_page_loads_path_created_at_idx
    ON robertseares_page_loads (path, created_at DESC);
