Class: Apartment::Adapters::Mysql2SchemaAdapter

Inherits:
AbstractAdapter show all
Defined in:
lib/apartment/adapters/mysql2_adapter.rb

Instance Attribute Summary

Attributes inherited from AbstractAdapter

#default_tenant

Instance Method Summary collapse

Methods inherited from AbstractAdapter

#create, #current, #drop, #each, #environmentify, #process_excluded_models, #seed_data, #switch, #switch!

Constructor Details

#initialize(config) ⇒ Mysql2SchemaAdapter

Returns a new instance of Mysql2SchemaAdapter.



30
31
32
33
34
35
# File 'lib/apartment/adapters/mysql2_adapter.rb', line 30

def initialize(config)
  super

  @default_tenant = config[:database]
  reset
end

Instance Method Details

#resetObject

Reset current tenant to the default_tenant



39
40
41
# File 'lib/apartment/adapters/mysql2_adapter.rb', line 39

def reset
  Apartment.connection.execute "use `#{default_tenant}`"
end