-- Generated by aether-data-schema from crates/aether-data/runtime/schema/logical/*.toml. -- Do not edit generated files directly; edit logical schema or explicit overrides instead. CREATE TABLE IF NOT EXISTS stats_hourly ( id TEXT PRIMARY KEY NOT NULL, hour_utc INTEGER NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, success_requests INTEGER NOT NULL DEFAULT 0, error_requests INTEGER NOT NULL DEFAULT 0, input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_tokens INTEGER NOT NULL DEFAULT 0, cache_read_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, actual_total_cost REAL NOT NULL DEFAULT 0, avg_response_time_ms REAL NOT NULL DEFAULT 0, is_complete INTEGER NOT NULL DEFAULT 0, aggregated_at INTEGER, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, response_time_sum_ms REAL NOT NULL DEFAULT 0, response_time_samples INTEGER NOT NULL DEFAULT 0, cache_hit_total_requests INTEGER NOT NULL DEFAULT 0, cache_hit_requests INTEGER NOT NULL DEFAULT 0, completed_total_requests INTEGER NOT NULL DEFAULT 0, completed_cache_hit_requests INTEGER NOT NULL DEFAULT 0, completed_input_tokens INTEGER NOT NULL DEFAULT 0, completed_cache_creation_tokens INTEGER NOT NULL DEFAULT 0, completed_cache_read_tokens INTEGER NOT NULL DEFAULT 0, completed_total_input_context INTEGER NOT NULL DEFAULT 0, completed_cache_creation_cost REAL NOT NULL DEFAULT 0, completed_cache_read_cost REAL NOT NULL DEFAULT 0, settled_total_cost REAL NOT NULL DEFAULT 0, settled_total_requests INTEGER NOT NULL DEFAULT 0, settled_input_tokens INTEGER NOT NULL DEFAULT 0, settled_output_tokens INTEGER NOT NULL DEFAULT 0, settled_cache_creation_tokens INTEGER NOT NULL DEFAULT 0, settled_cache_read_tokens INTEGER NOT NULL DEFAULT 0, settled_first_finalized_at_unix_secs INTEGER, settled_last_finalized_at_unix_secs INTEGER, UNIQUE (hour_utc) ); CREATE TABLE IF NOT EXISTS stats_summary ( id TEXT PRIMARY KEY NOT NULL, cutoff_date INTEGER NOT NULL, all_time_requests INTEGER NOT NULL DEFAULT 0, all_time_success_requests INTEGER NOT NULL DEFAULT 0, all_time_error_requests INTEGER NOT NULL DEFAULT 0, all_time_input_tokens INTEGER NOT NULL DEFAULT 0, all_time_output_tokens INTEGER NOT NULL DEFAULT 0, all_time_cache_creation_tokens INTEGER NOT NULL DEFAULT 0, all_time_cache_read_tokens INTEGER NOT NULL DEFAULT 0, all_time_cost REAL NOT NULL DEFAULT 0, all_time_actual_cost REAL NOT NULL DEFAULT 0, total_users INTEGER NOT NULL DEFAULT 0, active_users INTEGER NOT NULL DEFAULT 0, total_api_keys INTEGER NOT NULL DEFAULT 0, active_api_keys INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL ); CREATE TABLE IF NOT EXISTS stats_hourly_user ( id TEXT PRIMARY KEY NOT NULL, hour_utc INTEGER NOT NULL, user_id TEXT NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, success_requests INTEGER NOT NULL DEFAULT 0, error_requests INTEGER NOT NULL DEFAULT 0, input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, cache_creation_tokens INTEGER NOT NULL DEFAULT 0, cache_read_tokens INTEGER NOT NULL DEFAULT 0, actual_total_cost REAL NOT NULL DEFAULT 0, response_time_sum_ms REAL NOT NULL DEFAULT 0, response_time_samples INTEGER NOT NULL DEFAULT 0, settled_total_cost REAL NOT NULL DEFAULT 0, settled_total_requests INTEGER NOT NULL DEFAULT 0, settled_input_tokens INTEGER NOT NULL DEFAULT 0, settled_output_tokens INTEGER NOT NULL DEFAULT 0, settled_cache_creation_tokens INTEGER NOT NULL DEFAULT 0, settled_cache_read_tokens INTEGER NOT NULL DEFAULT 0, settled_first_finalized_at_unix_secs INTEGER, settled_last_finalized_at_unix_secs INTEGER, UNIQUE (hour_utc, user_id) ); CREATE TABLE IF NOT EXISTS stats_hourly_user_model ( id TEXT PRIMARY KEY NOT NULL, hour_utc INTEGER NOT NULL, user_id TEXT NOT NULL, model TEXT NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, response_time_sum_ms REAL NOT NULL DEFAULT 0, response_time_samples INTEGER NOT NULL DEFAULT 0, UNIQUE (hour_utc, user_id, model) ); CREATE TABLE IF NOT EXISTS user_model_usage_counts ( id TEXT PRIMARY KEY NOT NULL, user_id TEXT NOT NULL, model TEXT NOT NULL, usage_count INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (user_id, model) ); CREATE INDEX IF NOT EXISTS idx_user_model_usage_user ON user_model_usage_counts (user_id); CREATE INDEX IF NOT EXISTS idx_user_model_usage_model ON user_model_usage_counts (model); CREATE TABLE IF NOT EXISTS stats_hourly_model ( id TEXT PRIMARY KEY NOT NULL, hour_utc INTEGER NOT NULL, model TEXT NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, avg_response_time_ms REAL NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, response_time_sum_ms REAL NOT NULL DEFAULT 0, response_time_samples INTEGER NOT NULL DEFAULT 0, UNIQUE (hour_utc, model) ); CREATE TABLE IF NOT EXISTS stats_hourly_provider ( id TEXT PRIMARY KEY NOT NULL, hour_utc INTEGER NOT NULL, provider_name TEXT NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (hour_utc, provider_name) ); CREATE TABLE IF NOT EXISTS stats_daily ( id TEXT PRIMARY KEY NOT NULL, date INTEGER NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, success_requests INTEGER NOT NULL DEFAULT 0, error_requests INTEGER NOT NULL DEFAULT 0, input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_tokens INTEGER NOT NULL DEFAULT 0, cache_read_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, actual_total_cost REAL NOT NULL DEFAULT 0, input_cost REAL NOT NULL DEFAULT 0, output_cost REAL NOT NULL DEFAULT 0, cache_creation_cost REAL NOT NULL DEFAULT 0, cache_read_cost REAL NOT NULL DEFAULT 0, avg_response_time_ms REAL NOT NULL DEFAULT 0, fallback_count INTEGER NOT NULL DEFAULT 0, unique_models INTEGER NOT NULL DEFAULT 0, unique_providers INTEGER NOT NULL DEFAULT 0, is_complete INTEGER NOT NULL DEFAULT 0, aggregated_at INTEGER, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, p50_response_time_ms INTEGER, p90_response_time_ms INTEGER, p99_response_time_ms INTEGER, p50_first_byte_time_ms INTEGER, p90_first_byte_time_ms INTEGER, p99_first_byte_time_ms INTEGER, effective_input_tokens INTEGER NOT NULL DEFAULT 0, total_input_context INTEGER NOT NULL DEFAULT 0, response_time_sum_ms REAL NOT NULL DEFAULT 0, response_time_samples INTEGER NOT NULL DEFAULT 0, cache_creation_ephemeral_5m_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_ephemeral_1h_tokens INTEGER NOT NULL DEFAULT 0, cache_hit_total_requests INTEGER NOT NULL DEFAULT 0, cache_hit_requests INTEGER NOT NULL DEFAULT 0, completed_total_requests INTEGER NOT NULL DEFAULT 0, completed_cache_hit_requests INTEGER NOT NULL DEFAULT 0, completed_input_tokens INTEGER NOT NULL DEFAULT 0, completed_cache_creation_tokens INTEGER NOT NULL DEFAULT 0, completed_cache_read_tokens INTEGER NOT NULL DEFAULT 0, completed_total_input_context INTEGER NOT NULL DEFAULT 0, completed_cache_creation_cost REAL NOT NULL DEFAULT 0, completed_cache_read_cost REAL NOT NULL DEFAULT 0, settled_total_cost REAL NOT NULL DEFAULT 0, settled_total_requests INTEGER NOT NULL DEFAULT 0, settled_input_tokens INTEGER NOT NULL DEFAULT 0, settled_output_tokens INTEGER NOT NULL DEFAULT 0, settled_cache_creation_tokens INTEGER NOT NULL DEFAULT 0, settled_cache_read_tokens INTEGER NOT NULL DEFAULT 0, settled_first_finalized_at_unix_secs INTEGER, settled_last_finalized_at_unix_secs INTEGER, UNIQUE (date) ); CREATE TABLE IF NOT EXISTS stats_daily_model ( id TEXT PRIMARY KEY NOT NULL, date INTEGER NOT NULL, model TEXT NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_tokens INTEGER NOT NULL DEFAULT 0, cache_read_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, avg_response_time_ms REAL NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, response_time_sum_ms REAL NOT NULL DEFAULT 0, response_time_samples INTEGER NOT NULL DEFAULT 0, cache_creation_ephemeral_5m_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_ephemeral_1h_tokens INTEGER NOT NULL DEFAULT 0, UNIQUE (date, model) ); CREATE TABLE IF NOT EXISTS stats_daily_provider ( id TEXT PRIMARY KEY NOT NULL, date INTEGER NOT NULL, provider_name TEXT NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_tokens INTEGER NOT NULL DEFAULT 0, cache_read_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (date, provider_name) ); CREATE TABLE IF NOT EXISTS stats_daily_api_key ( id TEXT PRIMARY KEY NOT NULL, api_key_id TEXT NOT NULL, date INTEGER NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, success_requests INTEGER NOT NULL DEFAULT 0, error_requests INTEGER NOT NULL DEFAULT 0, input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_tokens INTEGER NOT NULL DEFAULT 0, cache_read_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, api_key_name TEXT, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (date, api_key_id) ); CREATE TABLE IF NOT EXISTS stats_daily_error ( id TEXT PRIMARY KEY NOT NULL, date INTEGER NOT NULL, error_category TEXT NOT NULL, provider_name TEXT, model TEXT, count INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (date, error_category, provider_name, model) ); CREATE TABLE IF NOT EXISTS stats_user_daily ( id TEXT PRIMARY KEY NOT NULL, user_id TEXT NOT NULL, date INTEGER NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, success_requests INTEGER NOT NULL DEFAULT 0, error_requests INTEGER NOT NULL DEFAULT 0, input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_tokens INTEGER NOT NULL DEFAULT 0, cache_read_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, username TEXT, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, actual_total_cost REAL NOT NULL DEFAULT 0, response_time_sum_ms REAL NOT NULL DEFAULT 0, response_time_samples INTEGER NOT NULL DEFAULT 0, effective_input_tokens INTEGER NOT NULL DEFAULT 0, total_input_context INTEGER NOT NULL DEFAULT 0, cache_creation_cost REAL NOT NULL DEFAULT 0, cache_read_cost REAL NOT NULL DEFAULT 0, cache_creation_ephemeral_5m_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_ephemeral_1h_tokens INTEGER NOT NULL DEFAULT 0, settled_total_cost REAL NOT NULL DEFAULT 0, settled_total_requests INTEGER NOT NULL DEFAULT 0, settled_input_tokens INTEGER NOT NULL DEFAULT 0, settled_output_tokens INTEGER NOT NULL DEFAULT 0, settled_cache_creation_tokens INTEGER NOT NULL DEFAULT 0, settled_cache_read_tokens INTEGER NOT NULL DEFAULT 0, settled_first_finalized_at_unix_secs INTEGER, settled_last_finalized_at_unix_secs INTEGER, UNIQUE (date, user_id) ); CREATE TABLE IF NOT EXISTS stats_user_summary ( id TEXT PRIMARY KEY NOT NULL, user_id TEXT NOT NULL, username TEXT, cutoff_date INTEGER NOT NULL, all_time_requests INTEGER NOT NULL DEFAULT 0, all_time_success_requests INTEGER NOT NULL DEFAULT 0, all_time_error_requests INTEGER NOT NULL DEFAULT 0, all_time_input_tokens INTEGER NOT NULL DEFAULT 0, all_time_output_tokens INTEGER NOT NULL DEFAULT 0, all_time_cache_creation_tokens INTEGER NOT NULL DEFAULT 0, all_time_cache_read_tokens INTEGER NOT NULL DEFAULT 0, all_time_cost REAL NOT NULL DEFAULT 0, all_time_actual_cost REAL NOT NULL DEFAULT 0, active_days INTEGER NOT NULL DEFAULT 0, first_active_date INTEGER, last_active_date INTEGER, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (user_id) ); CREATE INDEX IF NOT EXISTS idx_stats_user_summary_cutoff_date ON stats_user_summary (cutoff_date); CREATE TABLE IF NOT EXISTS stats_user_daily_model ( id TEXT PRIMARY KEY NOT NULL, user_id TEXT NOT NULL, username TEXT, date INTEGER NOT NULL, model TEXT NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, success_requests INTEGER NOT NULL DEFAULT 0, input_tokens INTEGER NOT NULL DEFAULT 0, effective_input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, total_tokens INTEGER NOT NULL DEFAULT 0, total_input_context INTEGER NOT NULL DEFAULT 0, cache_creation_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_ephemeral_5m_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_ephemeral_1h_tokens INTEGER NOT NULL DEFAULT 0, cache_read_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, actual_total_cost REAL NOT NULL DEFAULT 0, response_time_sum_ms REAL NOT NULL DEFAULT 0, response_time_samples INTEGER NOT NULL DEFAULT 0, successful_response_time_sum_ms REAL NOT NULL DEFAULT 0, successful_response_time_samples INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (user_id, date, model) ); CREATE INDEX IF NOT EXISTS idx_stats_user_daily_model_date ON stats_user_daily_model (date); CREATE INDEX IF NOT EXISTS idx_stats_user_daily_model_user_id ON stats_user_daily_model (user_id); CREATE TABLE IF NOT EXISTS stats_user_daily_provider ( id TEXT PRIMARY KEY NOT NULL, user_id TEXT NOT NULL, username TEXT, date INTEGER NOT NULL, provider_name TEXT NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, success_requests INTEGER NOT NULL DEFAULT 0, input_tokens INTEGER NOT NULL DEFAULT 0, effective_input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, total_tokens INTEGER NOT NULL DEFAULT 0, total_input_context INTEGER NOT NULL DEFAULT 0, cache_creation_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_ephemeral_5m_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_ephemeral_1h_tokens INTEGER NOT NULL DEFAULT 0, cache_read_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, actual_total_cost REAL NOT NULL DEFAULT 0, response_time_sum_ms REAL NOT NULL DEFAULT 0, response_time_samples INTEGER NOT NULL DEFAULT 0, successful_response_time_sum_ms REAL NOT NULL DEFAULT 0, successful_response_time_samples INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (user_id, date, provider_name) ); CREATE INDEX IF NOT EXISTS idx_stats_user_daily_provider_date ON stats_user_daily_provider (date); CREATE INDEX IF NOT EXISTS idx_stats_user_daily_provider_user_id ON stats_user_daily_provider (user_id); CREATE TABLE IF NOT EXISTS stats_user_daily_api_format ( id TEXT PRIMARY KEY NOT NULL, user_id TEXT NOT NULL, username TEXT, date INTEGER NOT NULL, api_format TEXT NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, success_requests INTEGER NOT NULL DEFAULT 0, input_tokens INTEGER NOT NULL DEFAULT 0, effective_input_tokens INTEGER NOT NULL DEFAULT 0, output_tokens INTEGER NOT NULL DEFAULT 0, total_tokens INTEGER NOT NULL DEFAULT 0, total_input_context INTEGER NOT NULL DEFAULT 0, cache_creation_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_ephemeral_5m_tokens INTEGER NOT NULL DEFAULT 0, cache_creation_ephemeral_1h_tokens INTEGER NOT NULL DEFAULT 0, cache_read_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, actual_total_cost REAL NOT NULL DEFAULT 0, response_time_sum_ms REAL NOT NULL DEFAULT 0, response_time_samples INTEGER NOT NULL DEFAULT 0, successful_response_time_sum_ms REAL NOT NULL DEFAULT 0, successful_response_time_samples INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (user_id, date, api_format) ); CREATE INDEX IF NOT EXISTS idx_stats_user_daily_api_format_date ON stats_user_daily_api_format (date); CREATE INDEX IF NOT EXISTS idx_stats_user_daily_api_format_user_id ON stats_user_daily_api_format (user_id); CREATE TABLE IF NOT EXISTS stats_daily_model_provider ( id TEXT PRIMARY KEY NOT NULL, date INTEGER NOT NULL, model TEXT NOT NULL, provider_name TEXT NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, total_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, response_time_sum_ms REAL NOT NULL DEFAULT 0, response_time_samples INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (date, model, provider_name) ); CREATE INDEX IF NOT EXISTS idx_stats_daily_model_provider_date ON stats_daily_model_provider (date); CREATE TABLE IF NOT EXISTS stats_user_daily_model_provider ( id TEXT PRIMARY KEY NOT NULL, user_id TEXT NOT NULL, username TEXT, date INTEGER NOT NULL, model TEXT NOT NULL, provider_name TEXT NOT NULL, total_requests INTEGER NOT NULL DEFAULT 0, total_tokens INTEGER NOT NULL DEFAULT 0, total_cost REAL NOT NULL DEFAULT 0, response_time_sum_ms REAL NOT NULL DEFAULT 0, response_time_samples INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (user_id, date, model, provider_name) ); CREATE INDEX IF NOT EXISTS idx_stats_user_daily_model_provider_date ON stats_user_daily_model_provider (date); CREATE INDEX IF NOT EXISTS idx_stats_user_daily_model_provider_user_date ON stats_user_daily_model_provider (user_id, date); CREATE TABLE IF NOT EXISTS stats_daily_cost_savings ( id TEXT PRIMARY KEY NOT NULL, date INTEGER NOT NULL, cache_read_tokens INTEGER NOT NULL DEFAULT 0, cache_read_cost REAL NOT NULL DEFAULT 0, cache_creation_cost REAL NOT NULL DEFAULT 0, estimated_full_cost REAL NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (date) ); CREATE TABLE IF NOT EXISTS stats_daily_cost_savings_provider ( id TEXT PRIMARY KEY NOT NULL, date INTEGER NOT NULL, provider_name TEXT NOT NULL, cache_read_tokens INTEGER NOT NULL DEFAULT 0, cache_read_cost REAL NOT NULL DEFAULT 0, cache_creation_cost REAL NOT NULL DEFAULT 0, estimated_full_cost REAL NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (date, provider_name) ); CREATE INDEX IF NOT EXISTS idx_stats_daily_cost_savings_provider_date ON stats_daily_cost_savings_provider (date); CREATE TABLE IF NOT EXISTS stats_daily_cost_savings_model ( id TEXT PRIMARY KEY NOT NULL, date INTEGER NOT NULL, model TEXT NOT NULL, cache_read_tokens INTEGER NOT NULL DEFAULT 0, cache_read_cost REAL NOT NULL DEFAULT 0, cache_creation_cost REAL NOT NULL DEFAULT 0, estimated_full_cost REAL NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (date, model) ); CREATE INDEX IF NOT EXISTS idx_stats_daily_cost_savings_model_date ON stats_daily_cost_savings_model (date); CREATE TABLE IF NOT EXISTS stats_daily_cost_savings_model_provider ( id TEXT PRIMARY KEY NOT NULL, date INTEGER NOT NULL, model TEXT NOT NULL, provider_name TEXT NOT NULL, cache_read_tokens INTEGER NOT NULL DEFAULT 0, cache_read_cost REAL NOT NULL DEFAULT 0, cache_creation_cost REAL NOT NULL DEFAULT 0, estimated_full_cost REAL NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (date, model, provider_name) ); CREATE INDEX IF NOT EXISTS idx_stats_daily_cost_savings_model_provider_date ON stats_daily_cost_savings_model_provider (date); CREATE TABLE IF NOT EXISTS stats_user_daily_cost_savings ( id TEXT PRIMARY KEY NOT NULL, user_id TEXT NOT NULL, username TEXT, date INTEGER NOT NULL, cache_read_tokens INTEGER NOT NULL DEFAULT 0, cache_read_cost REAL NOT NULL DEFAULT 0, cache_creation_cost REAL NOT NULL DEFAULT 0, estimated_full_cost REAL NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (user_id, date) ); CREATE INDEX IF NOT EXISTS idx_stats_user_daily_cost_savings_date ON stats_user_daily_cost_savings (date); CREATE TABLE IF NOT EXISTS stats_user_daily_cost_savings_provider ( id TEXT PRIMARY KEY NOT NULL, user_id TEXT NOT NULL, username TEXT, date INTEGER NOT NULL, provider_name TEXT NOT NULL, cache_read_tokens INTEGER NOT NULL DEFAULT 0, cache_read_cost REAL NOT NULL DEFAULT 0, cache_creation_cost REAL NOT NULL DEFAULT 0, estimated_full_cost REAL NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (user_id, date, provider_name) ); CREATE INDEX IF NOT EXISTS idx_stats_user_daily_cost_savings_provider_date ON stats_user_daily_cost_savings_provider (date); CREATE TABLE IF NOT EXISTS stats_user_daily_cost_savings_model ( id TEXT PRIMARY KEY NOT NULL, user_id TEXT NOT NULL, username TEXT, date INTEGER NOT NULL, model TEXT NOT NULL, cache_read_tokens INTEGER NOT NULL DEFAULT 0, cache_read_cost REAL NOT NULL DEFAULT 0, cache_creation_cost REAL NOT NULL DEFAULT 0, estimated_full_cost REAL NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (user_id, date, model) ); CREATE INDEX IF NOT EXISTS idx_stats_user_daily_cost_savings_model_date ON stats_user_daily_cost_savings_model (date); CREATE TABLE IF NOT EXISTS stats_user_daily_cost_savings_model_provider ( id TEXT PRIMARY KEY NOT NULL, user_id TEXT NOT NULL, username TEXT, date INTEGER NOT NULL, model TEXT NOT NULL, provider_name TEXT NOT NULL, cache_read_tokens INTEGER NOT NULL DEFAULT 0, cache_read_cost REAL NOT NULL DEFAULT 0, cache_creation_cost REAL NOT NULL DEFAULT 0, estimated_full_cost REAL NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, UNIQUE (user_id, date, model, provider_name) ); CREATE INDEX IF NOT EXISTS idx_stats_user_daily_cost_savings_model_provider_date ON stats_user_daily_cost_savings_model_provider (date);