こんにちは。Takitaです。
rails5からどのrailsバージョンでmigrationを作成したかという情報が追加されました。それにともないrails4で作成していたファイル全てにバージョン情報を付与するワンライナーで対応しました。
rails4で作成したmigrationファイルのまま bundle exec rails db:migrate
すると以下のようにエラーとこんな感じで書いてなというメッセージが表示されます。
$ be rails db:migrate
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:
class CreateUsers < ActiveRecord::Migration[4.2]
以下のコマンドで ActiveRecord::Migration
の後ろにバージョン( [4.2]
)をつけてあげます。
find db/migrate -name '*.rb' | xargs sed -i "" 's/ActiveRecord::Migration/ActiveRecord::Migration[4.2]/g'
これでmigrationも通るようになります。