Sha256: a9aeaf16808f3a72822ad5add51857b5404100a19469439ce3b64cf43477e982

Contents?: true

Size: 899 Bytes

Versions: 2

Compression:

Stored size: 899 Bytes

Contents

class Combustion::Databases::PostgreSQL < Combustion::Databases::Base
  def reset
    base.clear_active_connections!
    establish_connection(postgres_configuration)

    super
  end

  private

  def create
    connection.create_database(
      configuration['database'],
      configuration.merge('encoding' => encoding)
    )

  rescue Exception => error
    $stderr.puts error, *(error.backtrace)
    $stderr.puts "Couldn't create database for #{configuration.inspect}"
  end

  def drop
    connection.drop_database(configuration['database'])
  end

  def encoding
    configuration['encoding'] || ENV['CHARSET'] || 'utf8'
  end

  def postgres_configuration
    configuration.merge(
      'database'           => 'postgres',
      'schema_search_path' => schema_search_path
    )
  end

  def schema_search_path
    configuration['adapter'][/postgis/] ? 'public, postgis' : 'public'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
combustion-0.7.0 lib/combustion/databases/postgresql.rb
combustion-0.6.0 lib/combustion/databases/postgresql.rb