Class: LlmCostTracker::Doctor::SchemaCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/llm_cost_tracker/doctor/schema_check.rb

Instance Method Summary collapse

Constructor Details

#initialize(name:, schema:, table:) ⇒ SchemaCheck

Returns a new instance of SchemaCheck.



10
11
12
13
14
# File 'lib/llm_cost_tracker/doctor/schema_check.rb', line 10

def initialize(name:, schema:, table:)
  @name = name
  @schema = schema
  @table = table
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/llm_cost_tracker/doctor/schema_check.rb', line 16

def call
  return unless Probe.table_exists?("llm_cost_tracker_calls")

  errors = @schema.current_schema_errors
  return Check.new(:ok, @name, "#{@table} exists") if errors.empty?

  Check.new(
    :error,
    @name,
    "current schema required; #{errors.join('; ')}; " \
    "run bin/rails generate llm_cost_tracker:install && bin/rails db:migrate"
  )
end