Class: RubyLLM::Generators::OnlineCopyMigration::Journal
- Inherits:
-
Object
- Object
- RubyLLM::Generators::OnlineCopyMigration::Journal
- Defined in:
- lib/generators/ruby_llm/upgrade/online_copy_migration/journal.rb
Overview
:nodoc: all
Constant Summary collapse
- TABLE =
:ruby_llm_v2_changes- OPERATIONS =
%w[INSERT UPDATE DELETE].freeze
- MESSAGE_COLUMNS =
%w[ role content content_raw input_tokens output_tokens cached_tokens cache_creation_tokens cache_read_tokens cache_write_tokens thinking_tokens total_cost cost_details created_at updated_at ].freeze
Instance Method Summary collapse
-
#initialize(connection:, settings:) ⇒ Journal
constructor
A new instance of Journal.
- #install ⇒ Object
- #remove ⇒ Object
Constructor Details
#initialize(connection:, settings:) ⇒ Journal
Returns a new instance of Journal.
14 15 16 17 |
# File 'lib/generators/ruby_llm/upgrade/online_copy_migration/journal.rb', line 14 def initialize(connection:, settings:) @connection = connection @settings = settings end |
Instance Method Details
#install ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/generators/ruby_llm/upgrade/online_copy_migration/journal.rb', line 19 def install unless @connection.table_exists?(TABLE) @connection.create_table(TABLE) do |table| table.string :kind, null: false table.string :record_id, null: false table.bigint :revision, null: false, default: 1 table.index %i[kind record_id], unique: true end end sources.each do |kind, table| OPERATIONS.each { |operation| install_trigger(kind, table, operation) } end end |
#remove ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/generators/ruby_llm/upgrade/online_copy_migration/journal.rb', line 33 def remove sources.each do |kind, table| OPERATIONS.each do |operation| name = trigger_name(kind, operation) if postgresql? if @connection.table_exists?(table) @connection.execute("DROP TRIGGER IF EXISTS #{q(name)} ON #{qt(table)}") end @connection.execute("DROP FUNCTION IF EXISTS #{q(name)}()") else @connection.execute("DROP TRIGGER IF EXISTS #{q(name)}") end end end @connection.drop_table(TABLE) if @connection.table_exists?(TABLE) end |