Created
May 5, 2019 10:32
-
-
Save RajatGoyal/2029f26de9a957475e7256c8793d369b to your computer and use it in GitHub Desktop.
Monkey patch AbstractMysqlAdapter to set mysql 8 resource group while making a new connection
This file contains 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
require 'active_record/connection_adapters/abstract_mysql_adapter' | |
module ActiveRecord | |
module ConnectionAdapters | |
class AbstractMysqlAdapter | |
alias :old_configure_connection :configure_connection | |
def configure_connection | |
begin | |
execute 'SET RESOURCE GROUP etl' | |
rescue ActiveRecord::StatementInvalid | |
Rails.logger.warn "Unable to set resource group 'etl'" | |
end | |
old_configure_connection | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment