Sha256: 7bd9ceaef7d156a604e3d65f78f6f2d13aadb1ea5da2d40a043a4cb5156f22e2

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

# encoding: UTF-8

module Spontaneous::Cli
  class Init
    class Postgresql < Db

      def admin_connection_params
        config = super
        config.merge(database: 'postgres')
      end

      # On some machines the db creation fails due to incompabilities between the UTF8 encoding
      # and the configured locale.
      # You can force a locale for the db by adding LC_COLLATE & LC_CTYPE params
      # to the CREATE command:
      #
      #   LC_COLLATE='C.UTF-8' LC_CTYPE='C.UTF-8'
      #
      # but I don't know a good/the best way to determine the most appropriate UTF-8 locale
      # C.UTF-8 doesn't exist on OS X.
      def create_database_commands(opts)
        create_cmd = %(CREATE DATABASE "#{opts[:database]}" WITH TEMPLATE=template0 ENCODING='UTF8')
        cmds = []
        unless opts[:user].blank?
          create_cmd << %( OWNER="#{opts[:user]}")
          cmds << [%(CREATE ROLE "#{opts[:user]}" LOGIN PASSWORD '#{opts[:password]}'), false]
        end
        cmds << [create_cmd, true]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta10 lib/spontaneous/cli/init/postgresql.rb