Last active
April 23, 2019 02:49
-
-
Save a2ikm/a6eb77240d525382be548a7d6f59e946 to your computer and use it in GitHub Desktop.
rake db:migrateでdevelopmentだけでなくtestもまとめてマイグレーション走らせるやつ for Rails 5.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ActiveRecord::Tasks::DatabaseTasks | |
| class <<self | |
| prepend Module.new { | |
| def migrate(environment = env) | |
| each_current_configuration(environment) { |configuration| | |
| begin | |
| ActiveRecord::Base.establish_connection(configuration) | |
| super() | |
| ensure | |
| ActiveRecord::Base.establish_connection(environment.to_sym) | |
| end | |
| } | |
| end | |
| } | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment