Annotate past migrations with Rails version
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
This commit is contained in:
parent
2051540693
commit
5a890013ef
32 changed files with 32 additions and 32 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateBooths < ActiveRecord::Migration
|
||||
class CreateBooths < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :booths do |t|
|
||||
t.string :title
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue