CREATE TABLE access_logs
(
    id                BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
    request_id        TEXT,
    user_id           INTEGER,
    ip                INET,
    user_agent        TEXT,
    request_method    VARCHAR(10) NOT NULL,
    request_path      TEXT NOT NULL,
    referer           TEXT,
    message           TEXT,
    status_code       INTEGER,
    response_time_ms  INTEGER,
    started_at        TIMESTAMPTZ NOT NULL,
    created_at        TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_access_logs_created_at
    ON access_logs (created_at);

CREATE INDEX idx_access_logs_request_path
    ON access_logs (request_path);

CREATE INDEX idx_access_logs_ip
    ON access_logs (ip);