Merge pull request #2667 from AndrewKvalheim/fix-migration-non-null
Work around bug in migrations to non-null columns
This commit is contained in:
commit
9a04411f81
2 changed files with 5 additions and 1 deletions
|
|
@ -6,6 +6,8 @@ class MakeTrackStateNotNullAndAddDefaultValue < ActiveRecord::Migration[4.2]
|
||||||
end
|
end
|
||||||
|
|
||||||
def change
|
def change
|
||||||
|
TmpTrack.reset_column_information
|
||||||
|
|
||||||
TmpTrack.where(state: nil).each do |track|
|
TmpTrack.where(state: nil).each do |track|
|
||||||
track.state = 'confirmed'
|
track.state = 'confirmed'
|
||||||
track.save!
|
track.save!
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,13 @@ class MakeTrackCfpActiveNotNull < ActiveRecord::Migration[4.2]
|
||||||
end
|
end
|
||||||
|
|
||||||
def change
|
def change
|
||||||
|
TmpTrack.reset_column_information
|
||||||
|
|
||||||
TmpTrack.where(cfp_active: nil).each do |track|
|
TmpTrack.where(cfp_active: nil).each do |track|
|
||||||
track.cfp_active = true
|
track.cfp_active = true
|
||||||
track.save!
|
track.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
change_column_null :tracks, :cfp_active, false
|
change_column :tracks, :cfp_active, :boolean, null: false, default: false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue