Sha256: c69c3b7268967a2b36e3428ae7687240259bb755bcae3f5c9fdf8a5c08e3b825

Contents?: true

Size: 970 Bytes

Versions: 1

Compression:

Stored size: 970 Bytes

Contents

class Combustion::Databases::PostgreSQL < Combustion::Databases::Base
  def reset
    base.clear_active_connections!

    super
  end

  private

  def create
    establish_connection postgres_configuration
    connection.create_database configuration['database'],
      configuration.merge('encoding' => encoding)
    establish_connection configuration
  rescue Exception => error
    $stderr.puts error, *(error.backtrace)
    $stderr.puts "Couldn't create database for #{configuration.inspect}"
  end

  def drop
    establish_connection postgres_configuration
    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

1 entries across 1 versions & 1 rubygems

Version Path
combustion-0.5.5 lib/combustion/databases/postgresql.rb