Class: Nexo::Generators::ArtifactsGenerator

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

Overview

Adds the artifacts column to an already-installed nexo_workflow_runs table (Spec 7):

rails g nexo:artifacts

copies a timestamped, additive migration adding a json artifacts column (default []), after which rails db:migrate lets Nexo::Workflow runs record named artifacts. Fresh installs get the column from nexo:workflows directly; this generator is for apps installed before Spec 7. Modeled on WorkflowsGenerator.

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.



25
26
27
28
# File 'lib/generators/nexo/artifacts/artifacts_generator.rb', line 25

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 +artifacts+-column migration into db/migrate.



32
33
34
# File 'lib/generators/nexo/artifacts/artifacts_generator.rb', line 32

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