Module: BinInstall::Postgres

Defined in:
lib/bin_install/postgres.rb

Class Method Summary collapse

Class Method Details

.create_superuser(username = 'postgres') ⇒ Object



21
22
23
24
# File 'lib/bin_install/postgres.rb', line 21

def self.create_superuser(username = 'postgres')
  puts 'Creating superuser postgres for postgresqlSQL...'.white
  system("createuser --superuser #{username}")
end

.create_superuser!(username = 'postgres') ⇒ Object



26
27
28
29
# File 'lib/bin_install/postgres.rb', line 26

def self.create_superuser!(username = 'postgres')
  puts 'Creating superuser postgres for PostgreSQL...'.white
  BinInstall.system!("createuser --superuser #{username}")
end

.create_user(username = 'postgres') ⇒ Object



31
32
33
34
# File 'lib/bin_install/postgres.rb', line 31

def self.create_user(username = 'postgres')
  puts "Creating user #{username} for PostgreSQL".white
  system("createuser #{username}")
end

.create_user!(username = 'postgres') ⇒ Object



36
37
38
39
# File 'lib/bin_install/postgres.rb', line 36

def self.create_user!(username = 'postgres')
  puts "Creating user #{username} for PostgreSQL".white
  BinInstall.system!("createuser #{username}")
end

.install(version = nil) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/bin_install/postgres.rb', line 3

def self.install(version = nil)
  puts 'Installing PostgreSQL...'.white
  if version
    Brew::Package.install_or_upgrade("postgresql@#{version}")
  else
    Brew::Package.install_or_upgrade('postgresql')
  end
end

.install!(version = nil) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/bin_install/postgres.rb', line 12

def self.install!(version = nil)
  puts 'Installing PostgreSQL...'.white
  if version
    Brew::Package.install_or_upgrade!("postgresql@#{version}")
  else
    Brew::Package.install_or_upgrade!('postgresql')
  end
end

.installed?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/bin_install/postgres.rb', line 41

def self.installed?
  Shell.executable_exists?('psql')
end