Class: DenormalizePipelineKlassOnAvailabilities
- Inherits:
-
Ductwork::Migration
- Object
- Ductwork::Migration
- DenormalizePipelineKlassOnAvailabilities
- Defined in:
- lib/generators/ductwork/update/templates/db/denormalize_pipeline_klass_on_availabilities.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 |
# File 'lib/generators/ductwork/update/templates/db/denormalize_pipeline_klass_on_availabilities.rb', line 4 def change add_column :ductwork_availabilities, :pipeline_klass, :string # NOTE: change this how you see fit. everything is updated to a static, # bogus value in case there are a lot of records. Ductwork::Availability .where(pipeline_klass: nil) .update_all(pipeline_klass: "Pipeline") change_column_null :ductwork_availabilities, :pipeline_klass, false remove_index :ductwork_availabilities, name: "index_ductwork_availabilities_on_claim_latest" if mysql? add_index :ductwork_availabilities, %i[pipeline_klass completed_at started_at], name: "index_ductwork_availabilities_on_claim_latest" else add_index :ductwork_availabilities, %i[pipeline_klass started_at], name: "index_ductwork_availabilities_on_claim_latest", where: "completed_at IS NULL" end end |