feat: Fix tokens Revenue stream

This commit is contained in:
2026-03-19 14:54:31 -03:00
parent 686eb377f0
commit 0598fc4865
10 changed files with 1346 additions and 14 deletions
@@ -0,0 +1,3 @@
-- Dummy migration to satisfy SQLx
-- This migration was split into 20260319000001 and 20260319000002
SELECT 1;
@@ -1,10 +1,5 @@
-- AI Usage Logs: Add prompt and response fields for detailed tracking
-- This allows storing the actual prompts and responses for debugging and analytics
-- Add new columns to ai_usage_logs
ALTER TABLE ai_usage_logs
ADD COLUMN IF NOT EXISTS prompt TEXT,
ADD COLUMN IF NOT EXISTS response TEXT;
-- AI Usage Logs: Update log_ai_usage function to include prompt and response
-- Note: prompt and response columns already exist from previous migration
-- Update log_ai_usage function to accept prompt and response
CREATE OR REPLACE FUNCTION log_ai_usage(
@@ -44,9 +39,5 @@ BEGIN
END;
$$ LANGUAGE plpgsql;
-- Add indexes for text search (optional, can be enabled if needed for analytics)
-- CREATE INDEX idx_ai_usage_prompt ON ai_usage_logs USING gin (to_tsvector('spanish', prompt));
-- CREATE INDEX idx_ai_usage_response ON ai_usage_logs USING gin (to_tsvector('spanish', response));
COMMENT ON COLUMN ai_usage_logs.prompt IS 'The actual prompt sent to the AI model';
COMMENT ON COLUMN ai_usage_logs.response IS 'The AI model response content';