Skip to content

Instantly share code, notes, and snippets.

@a2ikm
Last active April 23, 2019 02:49
Show Gist options
  • Select an option

  • Save a2ikm/a6eb77240d525382be548a7d6f59e946 to your computer and use it in GitHub Desktop.

Select an option

Save a2ikm/a6eb77240d525382be548a7d6f59e946 to your computer and use it in GitHub Desktop.
rake db:migrateでdevelopmentだけでなくtestもまとめてマイグレーション走らせるやつ for Rails 5.1
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