Files
Aether/crates/aether-data/schema/logical/007_stats.toml
fawney19 fce7e959e5 Add multi-database data layer
Introduce aether-data-schema and driver-specific schema generation for Postgres, MySQL, and SQLite.

Split data backends, lifecycle, repositories, and gateway runtime integration across database drivers.

Verified with cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, and cargo test --workspace.
2026-05-05 18:27:36 +08:00

922 lines
16 KiB
TOML

[table.stats_hourly]
domain = "stats"
order = 10
primary_key = ["id"]
[[table.stats_hourly.columns]]
name = "id"
type = "text_id"
length = 64
[[table.stats_hourly.columns]]
name = "hour_utc"
type = "unix_seconds"
[[table.stats_hourly.columns]]
name = "total_requests"
type = "int64"
default = 0
[[table.stats_hourly.columns]]
name = "success_requests"
type = "int64"
default = 0
[[table.stats_hourly.columns]]
name = "error_requests"
type = "int64"
default = 0
[[table.stats_hourly.columns]]
name = "input_tokens"
type = "int64"
default = 0
[[table.stats_hourly.columns]]
name = "output_tokens"
type = "int64"
default = 0
[[table.stats_hourly.columns]]
name = "cache_creation_tokens"
type = "int64"
default = 0
[[table.stats_hourly.columns]]
name = "cache_read_tokens"
type = "int64"
default = 0
[[table.stats_hourly.columns]]
name = "total_cost"
type = "float64"
default = 0
[[table.stats_hourly.columns]]
name = "actual_total_cost"
type = "float64"
default = 0
[[table.stats_hourly.columns]]
name = "avg_response_time_ms"
type = "float64"
default = 0
[[table.stats_hourly.columns]]
name = "is_complete"
type = "bool"
default = false
[[table.stats_hourly.columns]]
name = "aggregated_at"
type = "unix_seconds"
nullable = true
[[table.stats_hourly.columns]]
name = "created_at"
type = "unix_seconds"
[[table.stats_hourly.columns]]
name = "updated_at"
type = "unix_seconds"
[[table.stats_hourly.uniques]]
name = "uq_stats_hourly_hour"
columns = ["hour_utc"]
[table.stats_summary]
domain = "stats"
order = 15
primary_key = ["id"]
[[table.stats_summary.columns]]
name = "id"
type = "text_id"
length = 64
[[table.stats_summary.columns]]
name = "cutoff_date"
type = "unix_seconds"
[[table.stats_summary.columns]]
name = "all_time_requests"
type = "int64"
default = 0
[[table.stats_summary.columns]]
name = "all_time_success_requests"
type = "int64"
default = 0
[[table.stats_summary.columns]]
name = "all_time_error_requests"
type = "int64"
default = 0
[[table.stats_summary.columns]]
name = "all_time_input_tokens"
type = "int64"
default = 0
[[table.stats_summary.columns]]
name = "all_time_output_tokens"
type = "int64"
default = 0
[[table.stats_summary.columns]]
name = "all_time_cache_creation_tokens"
type = "int64"
default = 0
[[table.stats_summary.columns]]
name = "all_time_cache_read_tokens"
type = "int64"
default = 0
[[table.stats_summary.columns]]
name = "all_time_cost"
type = "float64"
default = 0
[[table.stats_summary.columns]]
name = "all_time_actual_cost"
type = "float64"
default = 0
[[table.stats_summary.columns]]
name = "total_users"
type = "int64"
default = 0
[[table.stats_summary.columns]]
name = "active_users"
type = "int64"
default = 0
[[table.stats_summary.columns]]
name = "total_api_keys"
type = "int64"
default = 0
[[table.stats_summary.columns]]
name = "active_api_keys"
type = "int64"
default = 0
[[table.stats_summary.columns]]
name = "created_at"
type = "unix_seconds"
[[table.stats_summary.columns]]
name = "updated_at"
type = "unix_seconds"
[table.stats_hourly_user]
domain = "stats"
order = 20
primary_key = ["id"]
[[table.stats_hourly_user.columns]]
name = "id"
type = "text_id"
length = 64
[[table.stats_hourly_user.columns]]
name = "hour_utc"
type = "unix_seconds"
[[table.stats_hourly_user.columns]]
name = "user_id"
type = "text_id"
length = 64
[[table.stats_hourly_user.columns]]
name = "total_requests"
type = "int64"
default = 0
[[table.stats_hourly_user.columns]]
name = "success_requests"
type = "int64"
default = 0
[[table.stats_hourly_user.columns]]
name = "error_requests"
type = "int64"
default = 0
[[table.stats_hourly_user.columns]]
name = "input_tokens"
type = "int64"
default = 0
[[table.stats_hourly_user.columns]]
name = "output_tokens"
type = "int64"
default = 0
[[table.stats_hourly_user.columns]]
name = "total_cost"
type = "float64"
default = 0
[[table.stats_hourly_user.columns]]
name = "created_at"
type = "unix_seconds"
[[table.stats_hourly_user.columns]]
name = "updated_at"
type = "unix_seconds"
[[table.stats_hourly_user.uniques]]
name = "uq_stats_hourly_user"
columns = ["hour_utc", "user_id"]
[table.stats_hourly_user_model]
domain = "stats"
order = 30
primary_key = ["id"]
[[table.stats_hourly_user_model.columns]]
name = "id"
type = "text_id"
length = 64
[[table.stats_hourly_user_model.columns]]
name = "hour_utc"
type = "unix_seconds"
[[table.stats_hourly_user_model.columns]]
name = "user_id"
type = "text_id"
length = 64
[[table.stats_hourly_user_model.columns]]
name = "model"
type = "text"
length = 255
[[table.stats_hourly_user_model.columns]]
name = "total_requests"
type = "int64"
default = 0
[[table.stats_hourly_user_model.columns]]
name = "input_tokens"
type = "int64"
default = 0
[[table.stats_hourly_user_model.columns]]
name = "output_tokens"
type = "int64"
default = 0
[[table.stats_hourly_user_model.columns]]
name = "total_cost"
type = "float64"
default = 0
[[table.stats_hourly_user_model.columns]]
name = "created_at"
type = "unix_seconds"
[[table.stats_hourly_user_model.columns]]
name = "updated_at"
type = "unix_seconds"
[[table.stats_hourly_user_model.uniques]]
name = "uq_stats_hourly_user_model"
columns = ["hour_utc", "user_id", "model"]
[table.user_model_usage_counts]
domain = "stats"
order = 35
primary_key = ["id"]
[[table.user_model_usage_counts.columns]]
name = "id"
type = "text_id"
length = 64
[[table.user_model_usage_counts.columns]]
name = "user_id"
type = "text_id"
length = 64
[[table.user_model_usage_counts.columns]]
name = "model"
type = "text"
length = 255
[[table.user_model_usage_counts.columns]]
name = "usage_count"
type = "int64"
default = 0
[[table.user_model_usage_counts.columns]]
name = "created_at"
type = "unix_seconds"
[[table.user_model_usage_counts.columns]]
name = "updated_at"
type = "unix_seconds"
[[table.user_model_usage_counts.uniques]]
name = "uq_user_model_usage_count"
columns = ["user_id", "model"]
[[table.user_model_usage_counts.indexes]]
name = "idx_user_model_usage_user"
columns = ["user_id"]
[[table.user_model_usage_counts.indexes]]
name = "idx_user_model_usage_model"
columns = ["model"]
[table.stats_hourly_model]
domain = "stats"
order = 40
primary_key = ["id"]
[[table.stats_hourly_model.columns]]
name = "id"
type = "text_id"
length = 64
[[table.stats_hourly_model.columns]]
name = "hour_utc"
type = "unix_seconds"
[[table.stats_hourly_model.columns]]
name = "model"
type = "text"
length = 255
[[table.stats_hourly_model.columns]]
name = "total_requests"
type = "int64"
default = 0
[[table.stats_hourly_model.columns]]
name = "input_tokens"
type = "int64"
default = 0
[[table.stats_hourly_model.columns]]
name = "output_tokens"
type = "int64"
default = 0
[[table.stats_hourly_model.columns]]
name = "total_cost"
type = "float64"
default = 0
[[table.stats_hourly_model.columns]]
name = "avg_response_time_ms"
type = "float64"
default = 0
[[table.stats_hourly_model.columns]]
name = "created_at"
type = "unix_seconds"
[[table.stats_hourly_model.columns]]
name = "updated_at"
type = "unix_seconds"
[[table.stats_hourly_model.uniques]]
name = "uq_stats_hourly_model"
columns = ["hour_utc", "model"]
[table.stats_hourly_provider]
domain = "stats"
order = 50
primary_key = ["id"]
[[table.stats_hourly_provider.columns]]
name = "id"
type = "text_id"
length = 64
[[table.stats_hourly_provider.columns]]
name = "hour_utc"
type = "unix_seconds"
[[table.stats_hourly_provider.columns]]
name = "provider_name"
type = "text"
length = 255
[[table.stats_hourly_provider.columns]]
name = "total_requests"
type = "int64"
default = 0
[[table.stats_hourly_provider.columns]]
name = "input_tokens"
type = "int64"
default = 0
[[table.stats_hourly_provider.columns]]
name = "output_tokens"
type = "int64"
default = 0
[[table.stats_hourly_provider.columns]]
name = "total_cost"
type = "float64"
default = 0
[[table.stats_hourly_provider.columns]]
name = "created_at"
type = "unix_seconds"
[[table.stats_hourly_provider.columns]]
name = "updated_at"
type = "unix_seconds"
[[table.stats_hourly_provider.uniques]]
name = "uq_stats_hourly_provider"
columns = ["hour_utc", "provider_name"]
[table.stats_daily]
domain = "stats"
order = 60
primary_key = ["id"]
[[table.stats_daily.columns]]
name = "id"
type = "text_id"
length = 64
[[table.stats_daily.columns]]
name = "date"
type = "unix_seconds"
[[table.stats_daily.columns]]
name = "total_requests"
type = "int64"
default = 0
[[table.stats_daily.columns]]
name = "success_requests"
type = "int64"
default = 0
[[table.stats_daily.columns]]
name = "error_requests"
type = "int64"
default = 0
[[table.stats_daily.columns]]
name = "input_tokens"
type = "int64"
default = 0
[[table.stats_daily.columns]]
name = "output_tokens"
type = "int64"
default = 0
[[table.stats_daily.columns]]
name = "cache_creation_tokens"
type = "int64"
default = 0
[[table.stats_daily.columns]]
name = "cache_read_tokens"
type = "int64"
default = 0
[[table.stats_daily.columns]]
name = "total_cost"
type = "float64"
default = 0
[[table.stats_daily.columns]]
name = "actual_total_cost"
type = "float64"
default = 0
[[table.stats_daily.columns]]
name = "input_cost"
type = "float64"
default = 0
[[table.stats_daily.columns]]
name = "output_cost"
type = "float64"
default = 0
[[table.stats_daily.columns]]
name = "cache_creation_cost"
type = "float64"
default = 0
[[table.stats_daily.columns]]
name = "cache_read_cost"
type = "float64"
default = 0
[[table.stats_daily.columns]]
name = "avg_response_time_ms"
type = "float64"
default = 0
[[table.stats_daily.columns]]
name = "fallback_count"
type = "int64"
default = 0
[[table.stats_daily.columns]]
name = "unique_models"
type = "int64"
default = 0
[[table.stats_daily.columns]]
name = "unique_providers"
type = "int64"
default = 0
[[table.stats_daily.columns]]
name = "is_complete"
type = "bool"
default = false
[[table.stats_daily.columns]]
name = "aggregated_at"
type = "unix_seconds"
nullable = true
[[table.stats_daily.columns]]
name = "created_at"
type = "unix_seconds"
[[table.stats_daily.columns]]
name = "updated_at"
type = "unix_seconds"
[[table.stats_daily.columns]]
name = "p50_response_time_ms"
type = "int64"
nullable = true
[[table.stats_daily.columns]]
name = "p90_response_time_ms"
type = "int64"
nullable = true
[[table.stats_daily.columns]]
name = "p99_response_time_ms"
type = "int64"
nullable = true
[[table.stats_daily.columns]]
name = "p50_first_byte_time_ms"
type = "int64"
nullable = true
[[table.stats_daily.columns]]
name = "p90_first_byte_time_ms"
type = "int64"
nullable = true
[[table.stats_daily.columns]]
name = "p99_first_byte_time_ms"
type = "int64"
nullable = true
[[table.stats_daily.uniques]]
name = "uq_stats_daily_date"
columns = ["date"]
[table.stats_daily_model]
domain = "stats"
order = 70
primary_key = ["id"]
[[table.stats_daily_model.columns]]
name = "id"
type = "text_id"
length = 64
[[table.stats_daily_model.columns]]
name = "date"
type = "unix_seconds"
[[table.stats_daily_model.columns]]
name = "model"
type = "text"
length = 255
[[table.stats_daily_model.columns]]
name = "total_requests"
type = "int64"
default = 0
[[table.stats_daily_model.columns]]
name = "input_tokens"
type = "int64"
default = 0
[[table.stats_daily_model.columns]]
name = "output_tokens"
type = "int64"
default = 0
[[table.stats_daily_model.columns]]
name = "cache_creation_tokens"
type = "int64"
default = 0
[[table.stats_daily_model.columns]]
name = "cache_read_tokens"
type = "int64"
default = 0
[[table.stats_daily_model.columns]]
name = "total_cost"
type = "float64"
default = 0
[[table.stats_daily_model.columns]]
name = "avg_response_time_ms"
type = "float64"
default = 0
[[table.stats_daily_model.columns]]
name = "created_at"
type = "unix_seconds"
[[table.stats_daily_model.columns]]
name = "updated_at"
type = "unix_seconds"
[[table.stats_daily_model.uniques]]
name = "uq_stats_daily_model"
columns = ["date", "model"]
[table.stats_daily_provider]
domain = "stats"
order = 80
primary_key = ["id"]
[[table.stats_daily_provider.columns]]
name = "id"
type = "text_id"
length = 64
[[table.stats_daily_provider.columns]]
name = "date"
type = "unix_seconds"
[[table.stats_daily_provider.columns]]
name = "provider_name"
type = "text"
length = 255
[[table.stats_daily_provider.columns]]
name = "total_requests"
type = "int64"
default = 0
[[table.stats_daily_provider.columns]]
name = "input_tokens"
type = "int64"
default = 0
[[table.stats_daily_provider.columns]]
name = "output_tokens"
type = "int64"
default = 0
[[table.stats_daily_provider.columns]]
name = "cache_creation_tokens"
type = "int64"
default = 0
[[table.stats_daily_provider.columns]]
name = "cache_read_tokens"
type = "int64"
default = 0
[[table.stats_daily_provider.columns]]
name = "total_cost"
type = "float64"
default = 0
[[table.stats_daily_provider.columns]]
name = "created_at"
type = "unix_seconds"
[[table.stats_daily_provider.columns]]
name = "updated_at"
type = "unix_seconds"
[[table.stats_daily_provider.uniques]]
name = "uq_stats_daily_provider"
columns = ["date", "provider_name"]
[table.stats_daily_api_key]
domain = "stats"
order = 90
primary_key = ["id"]
[[table.stats_daily_api_key.columns]]
name = "id"
type = "text_id"
length = 64
[[table.stats_daily_api_key.columns]]
name = "api_key_id"
type = "text_id"
length = 64
[[table.stats_daily_api_key.columns]]
name = "date"
type = "unix_seconds"
[[table.stats_daily_api_key.columns]]
name = "total_requests"
type = "int64"
default = 0
[[table.stats_daily_api_key.columns]]
name = "success_requests"
type = "int64"
default = 0
[[table.stats_daily_api_key.columns]]
name = "error_requests"
type = "int64"
default = 0
[[table.stats_daily_api_key.columns]]
name = "input_tokens"
type = "int64"
default = 0
[[table.stats_daily_api_key.columns]]
name = "output_tokens"
type = "int64"
default = 0
[[table.stats_daily_api_key.columns]]
name = "cache_creation_tokens"
type = "int64"
default = 0
[[table.stats_daily_api_key.columns]]
name = "cache_read_tokens"
type = "int64"
default = 0
[[table.stats_daily_api_key.columns]]
name = "total_cost"
type = "float64"
default = 0
[[table.stats_daily_api_key.columns]]
name = "api_key_name"
type = "text"
length = 255
nullable = true
[[table.stats_daily_api_key.columns]]
name = "created_at"
type = "unix_seconds"
[[table.stats_daily_api_key.columns]]
name = "updated_at"
type = "unix_seconds"
[[table.stats_daily_api_key.uniques]]
name = "uq_stats_daily_api_key"
columns = ["date", "api_key_id"]
[table.stats_daily_error]
domain = "stats"
order = 100
primary_key = ["id"]
[[table.stats_daily_error.columns]]
name = "id"
type = "text_id"
length = 64
[[table.stats_daily_error.columns]]
name = "date"
type = "unix_seconds"
[[table.stats_daily_error.columns]]
name = "error_category"
type = "text"
length = 255
[[table.stats_daily_error.columns]]
name = "provider_name"
type = "text"
length = 255
nullable = true
[[table.stats_daily_error.columns]]
name = "model"
type = "text"
length = 255
nullable = true
[[table.stats_daily_error.columns]]
name = "count"
type = "int64"
default = 0
[[table.stats_daily_error.columns]]
name = "created_at"
type = "unix_seconds"
[[table.stats_daily_error.columns]]
name = "updated_at"
type = "unix_seconds"
[[table.stats_daily_error.uniques]]
name = "uq_stats_daily_error"
columns = ["date", "error_category", "provider_name", "model"]
[table.stats_user_daily]
domain = "stats"
order = 110
primary_key = ["id"]
[[table.stats_user_daily.columns]]
name = "id"
type = "text_id"
length = 64
[[table.stats_user_daily.columns]]
name = "user_id"
type = "text_id"
length = 64
[[table.stats_user_daily.columns]]
name = "date"
type = "unix_seconds"
[[table.stats_user_daily.columns]]
name = "total_requests"
type = "int64"
default = 0
[[table.stats_user_daily.columns]]
name = "success_requests"
type = "int64"
default = 0
[[table.stats_user_daily.columns]]
name = "error_requests"
type = "int64"
default = 0
[[table.stats_user_daily.columns]]
name = "input_tokens"
type = "int64"
default = 0
[[table.stats_user_daily.columns]]
name = "output_tokens"
type = "int64"
default = 0
[[table.stats_user_daily.columns]]
name = "cache_creation_tokens"
type = "int64"
default = 0
[[table.stats_user_daily.columns]]
name = "cache_read_tokens"
type = "int64"
default = 0
[[table.stats_user_daily.columns]]
name = "total_cost"
type = "float64"
default = 0
[[table.stats_user_daily.columns]]
name = "username"
type = "text"
length = 255
nullable = true
[[table.stats_user_daily.columns]]
name = "created_at"
type = "unix_seconds"
[[table.stats_user_daily.columns]]
name = "updated_at"
type = "unix_seconds"
[[table.stats_user_daily.uniques]]
name = "uq_stats_user_daily"
columns = ["date", "user_id"]