-- Migration 007: track /prices API callers
SET search_path TO crawl;

CREATE TABLE IF NOT EXISTS price_api_logs (
    id         BIGSERIAL    PRIMARY KEY,
    ip         VARCHAR(45)  NOT NULL,
    referer    TEXT,
    org        VARCHAR(200),
    country    VARCHAR(100),
    city       VARCHAR(100),
    created_at TIMESTAMPTZ  NOT NULL DEFAULT NOW()
);

CREATE INDEX IF NOT EXISTS idx_price_api_logs_created_at ON price_api_logs (created_at DESC);
CREATE INDEX IF NOT EXISTS idx_price_api_logs_ip ON price_api_logs (ip);
