Class: CreateDuctworkBranches
- Inherits:
-
Ductwork::Migration
- Object
- Ductwork::Migration
- CreateDuctworkBranches
- Defined in:
- lib/generators/ductwork/update/templates/db/create_ductwork_branches.rb,
lib/generators/ductwork/install/templates/db/create_ductwork_branches.rb
Instance Method Summary collapse
Methods included from Ductwork::MigrationHelper
#belongs_to, #create_ductwork_table, #mysql?, #postgresql?, #uuid_column_type
Instance Method Details
#change ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/ductwork/update/templates/db/create_ductwork_branches.rb', line 4 def change create_ductwork_table :ductwork_branches do |table| belongs_to( table, :pipeline, index: true, null: false, foreign_key: { to_table: :ductwork_pipelines } ) table.string :pipeline_klass, null: false table.string :status, null: false table.string :halt_reason table.string :claim_token table.datetime :claimed_for_advancing_at table.datetime :last_advanced_at, null: false table.datetime :started_at, null: false table.datetime :completed_at table. null: false end if mysql? add_index :ductwork_branches, %w[pipeline_klass status claimed_for_advancing_at last_advanced_at], name: "index_ductwork_branches_on_claim_latest" else add_index :ductwork_branches, %w[pipeline_klass status last_advanced_at], where: "claimed_for_advancing_at IS NULL", name: "index_ductwork_branches_on_claim_latest" end add_index :ductwork_branches, %w[pipeline_id started_at] add_index :ductwork_branches, %w[run_id status] end |