Module: PatchedEnv

Defined in:
lib/patched/env.rb

Instance Method Summary collapse

Instance Method Details

#dbObject

Monkey patch to support Cloud SQL as an adapter



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/patched/env.rb', line 22

def db
  return @db if @db

  @db = if config[:db_adapter] == "cloud_sql"
      connection = Sequel.connect config.database_connection_config
      migrate_cloud_sql connection
      connection
    else
      super
    end
end

#migrate_cloud_sql(database) ⇒ Object



34
35
36
37
38
39
# File 'lib/patched/env.rb', line 34

def migrate_cloud_sql database
  Sequel.extension :migration
  lib_dir = Gem::Specification.find_by_name("gemstash").lib_dirs_glob
  m_dir = "#{lib_dir}/gemstash/migrations"
  Sequel::Migrator.run database, m_dir, use_transactions: false
end