Module: LlmCostTracker::Ledger::Schema::CallLineItems

Defined in:
lib/llm_cost_tracker/ledger/schema/call_line_items.rb

Constant Summary collapse

REQUIRED_COLUMNS =
%w[
  llm_cost_tracker_call_id
  position
  kind
  direction
  modality
  cache_state
  quantity
  unit
  rate_amount
  rate_quantity
  cost
  currency
  cost_status
  pricing_basis
  price_key
  price_source
  price_source_version
  provider_field
  provider_item_id
  details
].freeze

Class Method Summary collapse

Class Method Details

.current_schema_errorsObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/llm_cost_tracker/ledger/schema/call_line_items.rb', line 33

def current_schema_errors
  connection = LlmCostTracker::Call.connection
  Adapter.ensure_supported!(connection)
  table_name = LlmCostTracker::CallLineItem.table_name
  return ["#{table_name} table is missing"] unless connection.data_source_exists?(table_name)

  columns = LlmCostTracker::CallLineItem.columns_hash
  errors = []
  missing = REQUIRED_COLUMNS - columns.keys
  errors << "missing columns: #{missing.join(', ')}" if missing.any?
  errors.concat(Adapter.json_column_errors(columns["details"], connection, "details"))
  errors
end