Class: Nexo::Generators::StateGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Nexo::Generators::StateGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/nexo/state/state_generator.rb
Overview
Adds the state column to an already-installed nexo_workflow_runs table
(Spec 13):
rails g nexo:state
copies a timestamped, additive migration adding a json state column
(default {}), after which rails db:migrate lets Nexo::Workflow runs
store checkpoint results and suspend metadata (durable suspend/resume).
Fresh installs get the column from nexo:workflows directly; this generator
is for apps installed before Spec 13. Modeled on ArtifactsGenerator.
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Required by Rails::Generators::Migration to produce the migration's timestamp prefix.
Instance Method Summary collapse
-
#create_migration_file ⇒ Object
Generation step: copy the timestamped +state+-column migration into
db/migrate.
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/state/state_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_file ⇒ Object
Generation step: copy the timestamped +state+-column migration into
db/migrate.
32 33 34 |
# File 'lib/generators/nexo/state/state_generator.rb', line 32 def create_migration_file migration_template "add_state_to_nexo_workflow_runs.rb", "db/migrate/add_state_to_nexo_workflow_runs.rb" end |