Module: LlmCostTracker::Ledger::Schema::IngestionInboxEntries

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

Constant Summary collapse

REQUIRED_COLUMNS =
%w[
  event_id
  total_cost
  tracked_at
  payload
  locked_at
  locked_by
  attempts
  last_error
  created_at
  updated_at
].freeze
UNIQUE_COLUMNS =
%i[event_id].freeze

Class Method Summary collapse

Class Method Details

.current_schema_errorsObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/llm_cost_tracker/ledger/schema/ingestion_inbox_entries.rb', line 25

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

  columns = LlmCostTracker::Ingestion::InboxEntry.columns_hash
  cache = @schema_capabilities
  return cache.fetch(:errors) if cache && cache.fetch(:columns).equal?(columns)

  errors = compute_errors(connection, table_name, columns)
  @schema_capabilities = { columns: columns, errors: errors }
  errors
end