Class: RubyLlmAgents::RenameAgentGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/ruby_llm_agents/rename_agent_generator.rb

Overview

Generator for creating a migration to rename an agent in execution records

Usage:

rails generate ruby_llm_agents:rename_agent OldAgentName NewAgentName

This creates a reversible migration that updates the agent_type column in the ruby_llm_agents_executions table.

Instance Method Summary collapse

Instance Method Details

#create_migration_fileObject



29
30
31
32
33
34
# File 'lib/generators/ruby_llm_agents/rename_agent_generator.rb', line 29

def create_migration_file
  migration_template(
    "rename_agent_migration.rb.tt",
    File.join(db_migrate_path, "rename_#{old_name.underscore}_to_#{new_name.underscore}.rb")
  )
end

#show_messageObject



36
37
38
39
40
41
# File 'lib/generators/ruby_llm_agents/rename_agent_generator.rb', line 36

def show_message
  say ""
  say "Created migration to rename #{old_name} -> #{new_name}", :green
  say "Run `rails db:migrate` to apply."
  say ""
end

#validate_namesObject



23
24
25
26
27
# File 'lib/generators/ruby_llm_agents/rename_agent_generator.rb', line 23

def validate_names
  if old_name == new_name
    raise Thor::Error, "Old and new agent names must be different"
  end
end