class Blacksand::Migrations
Public Instance Methods
fix_migration_super_class()
click to toggle source
修正 migration 的父类,默认是 ActiveRecord::Migration, 但是 Rails 5.1 以后, 必须指定版本,例如 ActiveRecord::Migration
# File lib/blacksand/migrations.rb, line 9 def fix_migration_super_class if ActiveRecord::VERSION::MAJOR > 5 || ( ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR >= 1 ) puts "Fix migration super class" Dir.glob("db/migrate/*.blacksand.rb") do |file| gsub_file(file, /ActiveRecord::Migration$/, "ActiveRecord::Migration[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]") end end end