Class: LlmCostTracker::Doctor::SchemaCheck
- Inherits:
-
Object
- Object
- LlmCostTracker::Doctor::SchemaCheck
- Defined in:
- lib/llm_cost_tracker/doctor/schema_check.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(name:, schema:, table:, optional: false, install_command: "llm_cost_tracker:install") ⇒ SchemaCheck
constructor
A new instance of SchemaCheck.
Constructor Details
#initialize(name:, schema:, table:, optional: false, install_command: "llm_cost_tracker:install") ⇒ SchemaCheck
Returns a new instance of SchemaCheck.
10 11 12 13 14 15 16 |
# File 'lib/llm_cost_tracker/doctor/schema_check.rb', line 10 def initialize(name:, schema:, table:, optional: false, install_command: "llm_cost_tracker:install") @name = name @schema = schema @table = table @optional = optional @install_command = install_command end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/llm_cost_tracker/doctor/schema_check.rb', line 18 def call return unless Probe.table_exists?("llm_cost_tracker_calls") return if @optional && !Probe.table_exists?(@table) 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 #{@install_command} && bin/rails db:migrate" ) end |