Module: LlmCostTracker::Ledger::Schema::PeriodTotals

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

Constant Summary collapse

REQUIRED_COLUMNS =
%w[period period_start total_cost].freeze
UNIQUE_COLUMNS =
%i[period period_start].freeze

Class Method Summary collapse

Class Method Details

.current_schema_errorsObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/llm_cost_tracker/ledger/schema/period_totals.rb', line 11

def current_schema_errors
  connection = Ledger::Call.connection
  table_name = Ledger::Period::Total.table_name
  return ["llm_cost_tracker_period_totals table is missing"] unless connection.data_source_exists?(table_name)

  errors = []
  missing = REQUIRED_COLUMNS - Ledger::Period::Total.columns_hash.keys
  errors << "missing columns: #{missing.join(', ')}" if missing.any?
  errors << "missing unique index: period, period_start" unless unique_period_index?(connection, table_name)
  errors
end