Module: ActiveRecord::ConnectionHandling
- Defined in:
- lib/active_record/connection_adapters/mysql2_ghost_adapter.rb
Instance Method Summary collapse
-
#mysql2_ghost_connection(config) ⇒ Object
Establishes a connection to the database that’s used by all Active Record objects.
Instance Method Details
#mysql2_ghost_connection(config) ⇒ Object
Establishes a connection to the database that’s used by all Active Record objects.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/active_record/connection_adapters/mysql2_ghost_adapter.rb', line 10 def mysql2_ghost_connection(config) config = config.symbolize_keys config[:flags] ||= 0 if config[:flags].is_a? Array config[:flags].push 'FOUND_ROWS'.freeze else config[:flags] |= Mysql2::Client::FOUND_ROWS end client = Mysql2::Client.new(config) if GhostAdapter::Internal.ghost_migration_enabled? dry_run = ENV.fetch('DRY_RUN', nil) == '1' GhostAdapter::VersionChecker.validate_executable! unless ENV.fetch('SKIP_GHOST_VERSION_CHECK', nil) == '1' ConnectionAdapters::Mysql2GhostAdapter.new(client, logger, nil, config, dry_run: dry_run) else ConnectionAdapters::Mysql2Adapter.new(client, logger, nil, config) end rescue Mysql2::Error => e raise ActiveRecord::NoDatabaseError if e..include?('Unknown database') raise end |