Class: Nexo::Generators::WorkflowsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/nexo/workflows/workflows_generator.rb

Overview

Installs the WorkflowRun persistence schema into a host Rails app:

rails g nexo:workflows

copies a timestamped migration that creates the nexo_workflow_runs table, after which rails db:migrate makes Nexo::Workflow runs persist to ActiveRecord instead of the in-memory store.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

Required by Rails::Generators::Migration to produce the migration's timestamp prefix.



22
23
24
25
# File 'lib/generators/nexo/workflows/workflows_generator.rb', line 22

def self.next_migration_number(dirname)
  next_migration_number = current_migration_number(dirname) + 1
  ::ActiveRecord::Migration.next_migration_number(next_migration_number)
end

Instance Method Details

#create_migration_fileObject

Generation step: copy the timestamped create_nexo_workflow_runs migration into db/migrate.



29
30
31
# File 'lib/generators/nexo/workflows/workflows_generator.rb', line 29

def create_migration_file
  migration_template "create_nexo_workflow_runs.rb", "db/migrate/create_nexo_workflow_runs.rb"
end