Class: RubynCode::Tools::DbMigrate

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyn_code/tools/db_migrate.rb

Constant Summary collapse

TOOL_NAME =
'db_migrate'
DESCRIPTION =
'Runs Rails database migrations (up) or rollback (down).'
PARAMETERS =
{
  direction: { type: :string, required: false, default: 'up', enum: %w[up down],
               description: "Migration direction: 'up' to migrate, 'down' to rollback (default: 'up')" },
  steps: { type: :integer, required: false,
           description: "Number of steps to rollback (only used with direction 'down')" }
}.freeze
RISK_LEVEL =
:execute
REQUIRES_CONFIRMATION =
false

Instance Attribute Summary

Attributes inherited from Base

#project_root

Instance Method Summary collapse

Methods inherited from Base

description, #initialize, parameters, requires_confirmation?, risk_level, #safe_path, summarize, to_schema, tool_name, #truncate

Constructor Details

This class inherits a constructor from RubynCode::Tools::Base

Instance Method Details

#execute(direction: 'up', steps: nil) ⇒ Object



21
22
23
24
25
26
# File 'lib/rubyn_code/tools/db_migrate.rb', line 21

def execute(direction: 'up', steps: nil)
  command = build_command(direction, steps)
  stdout, stderr, status = safe_capture3(command, chdir: project_root)

  build_output(stdout, stderr, status)
end