Sha256: 7b97f4bc0a9de04a1368ac8654e8c610fc27a36cb97381873d30cdbb7f38ac1a

Contents?: true

Size: 908 Bytes

Versions: 7

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

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 StandardError => error
    warn error, *error.backtrace
    warn "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

7 entries across 7 versions & 1 rubygems

Version Path
combustion-1.3.7 lib/combustion/databases/postgresql.rb
combustion-1.3.6 lib/combustion/databases/postgresql.rb
combustion-1.3.5 lib/combustion/databases/postgresql.rb
combustion-1.3.4 lib/combustion/databases/postgresql.rb
combustion-1.3.3 lib/combustion/databases/postgresql.rb
combustion-1.3.2 lib/combustion/databases/postgresql.rb
combustion-1.3.1 lib/combustion/databases/postgresql.rb