Class: AddCrashCountToDuctworkExecutions

Inherits:
Ductwork::Migration show all
Defined in:
lib/generators/ductwork/update/templates/db/add_crash_count_to_ductwork_executions.rb

Instance Method Summary collapse

Methods included from Ductwork::MigrationHelper

#belongs_to, #create_ductwork_table, #mysql?, #postgresql?, #uuid_column_type

Instance Method Details

#changeObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/generators/ductwork/update/templates/db/add_crash_count_to_ductwork_executions.rb', line 4

def change
  add_column :ductwork_executions, :crash_count, :integer

  # NOTE: change this how you see fit for your scale
  Ductwork::Execution
    .where(crash_count: nil)
    .update_all(crash_count: 0)

  change_column_null :ductwork_executions, :crash_count, false
end