187_add_usage_log_session_id.sql 870 B

1234567891011121314
  1. -- Persist the explicit client-provided request session/conversation identifier
  2. -- (e.g. the session_id / X-Session-Id / X-Conversation-ID request headers) so
  3. -- usage rows can be correlated by session for querying.
  4. --
  5. -- Nullable with no default: on PostgreSQL 11+ this is a metadata-only change, so
  6. -- it does NOT rewrite the (potentially large) usage_logs table. Absent/invalid
  7. -- session identifiers stay NULL. Only explicit client correlation identity is
  8. -- stored here; prompt_cache_key and content-derived sticky hashes are never
  9. -- persisted as session_id.
  10. ALTER TABLE usage_logs ADD COLUMN IF NOT EXISTS session_id VARCHAR(255);
  11. -- Batch image usage is recorded asynchronously after the originating HTTP
  12. -- request has finished, so retain the same sanitized identifier on the job.
  13. ALTER TABLE batch_image_jobs ADD COLUMN IF NOT EXISTS session_id VARCHAR(255);