mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Many migrations currently fail to run with:
> Directly inheriting from ActiveRecord::Migration is not supported.
> Please specify the Rails release the migration was written for:
>
> class Example < ActiveRecord::Migration[4.2]
I've annotated those that I need to run with the Rails version at the
time each was committed:
rake db:migrate:status \
| grep --perl-regexp --only-matching '(?<=^ down )\d{14}' \
| while read -r id; do
path="$(ls -1 db/migrate/${id}_*.rb)"
version="$(git show "$(git log --diff-filter=A --pretty=format:%H -- "$path")":Gemfile.lock \
| grep --perl-regexp --only-matching '(?<=^ rails \()\d+\.\d+(?=(\.\d+)+\))')"
sed --in-place -e "s/\(< ActiveRecord::Migration\)$/\\1[$version]/" "$path"
done
16 lines
353 B
Ruby
16 lines
353 B
Ruby
# frozen_string_literal: true
|
|
|
|
class MakeTrackCfpActiveNotNull < ActiveRecord::Migration[4.2]
|
|
class TmpTrack < ActiveRecord::Base
|
|
self.table_name = 'tracks'
|
|
end
|
|
|
|
def change
|
|
TmpTrack.where(cfp_active: nil).each do |track|
|
|
track.cfp_active = true
|
|
track.save!
|
|
end
|
|
|
|
change_column_null :tracks, :cfp_active, false
|
|
end
|
|
end
|