Merge pull request #2667 from AndrewKvalheim/fix-migration-non-null

Work around bug in migrations to non-null columns
This commit is contained in:
Henne Vogelsang 2021-03-06 21:02:13 +01:00 committed by GitHub
commit 9a04411f81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -6,6 +6,8 @@ class MakeTrackStateNotNullAndAddDefaultValue < ActiveRecord::Migration[4.2]
end
def change
TmpTrack.reset_column_information
TmpTrack.where(state: nil).each do |track|
track.state = 'confirmed'
track.save!

View file

@ -6,11 +6,13 @@ class MakeTrackCfpActiveNotNull < ActiveRecord::Migration[4.2]
end
def change
TmpTrack.reset_column_information
TmpTrack.where(cfp_active: nil).each do |track|
track.cfp_active = true
track.save!
end
change_column_null :tracks, :cfp_active, false
change_column :tracks, :cfp_active, :boolean, null: false, default: false
end
end