Class: Brillo::Adapter::Base

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/brillo/adapter/base.rb

Direct Known Subclasses

MySQL, Postgres

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logger

#logger, logger, logger=

Constructor Details

#initialize(db_config) ⇒ Base

Returns a new instance of Base.



7
8
9
# File 'lib/brillo/adapter/base.rb', line 7

def initialize(db_config)
  @config = db_config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/brillo/adapter/base.rb', line 6

def config
  @config
end

Instance Method Details

#dump_structure_and_migrations(config) ⇒ Object



22
23
24
25
26
# File 'lib/brillo/adapter/base.rb', line 22

def dump_structure_and_migrations(config)
  # Overrides the path the structure is dumped to in Rails >= 3.2
  ENV['SCHEMA'] = ENV['DB_STRUCTURE'] = config.dump_path.to_s
  Rake::Task["db:structure:dump"].invoke
end


14
15
16
# File 'lib/brillo/adapter/base.rb', line 14

def footer
  ""
end

#headerObject



10
11
12
# File 'lib/brillo/adapter/base.rb', line 10

def header
  ActiveRecord::Base.connection.dump_schema_information
end

#load_commandObject

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/brillo/adapter/base.rb', line 28

def load_command
  raise NotImplementedError
end

#recreate_dbObject



32
33
34
35
36
37
# File 'lib/brillo/adapter/base.rb', line 32

def recreate_db
  ["db:drop", "db:create"].each do |t|
    logger.info "Running\n\trake #{t}"
    Rake::Task[t].invoke
  end
end


18
19
20
# File 'lib/brillo/adapter/base.rb', line 18

def table_footer(klass)
  ""
end