-- +goose Up
CREATE TABLE IF NOT EXISTS proxy_request_logs (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    host TEXT NOT NULL DEFAULT '',
    network TEXT NOT NULL DEFAULT '',
    rule_type TEXT NOT NULL DEFAULT '',
    rule_payload TEXT NOT NULL DEFAULT '',
    rule_line TEXT NOT NULL DEFAULT '',
    outbound_node TEXT NOT NULL DEFAULT '',
    outbound_chain TEXT NOT NULL DEFAULT '',
    upload INTEGER NOT NULL DEFAULT 0,
    download INTEGER NOT NULL DEFAULT 0,
    success INTEGER NOT NULL DEFAULT 0,
    started_at TEXT NOT NULL,
    ended_at TEXT NOT NULL,
    created_at TEXT NOT NULL DEFAULT (datetime('now'))
);

CREATE INDEX IF NOT EXISTS idx_proxy_request_logs_created ON proxy_request_logs(created_at DESC);
CREATE INDEX IF NOT EXISTS idx_proxy_request_logs_host ON proxy_request_logs(host);

-- +goose Down
DROP TABLE IF EXISTS proxy_request_logs;
