class ActiveScripts::Packages::Postgresql

Private Instance Methods

install() click to toggle source

INFO: ActiveScripts::Packages::Postgresql contains code that

execute the PostgreSQL package.
# File lib/active_scripts/packages/postgresql.rb, line 10
def install
  if package_installed?(includes: "postgresql")
    notify_package_exists!
  else
    case $operating_system
    when :macosx
      execute_command!("brew install postgresql")
      say_ok("   Installation complete!")
    when :linux
      if agree("   [?] PostgreSQL client only? ", true)
        execute_command!("sudo apt-get -y install postgresql-dev-9.4")
      else
        execute_command!("sudo apt-get -y install postgresql postgresql-contrib libpq-dev")
      end
      say_ok("   Installation complete!")
    else
      notify_package_unavailable!
    end
  end
end
uninstall() click to toggle source
# File lib/active_scripts/packages/postgresql.rb, line 49
def uninstall
  if package_installed?(includes: "postgresql")
    case $operating_system
    when :macosx
      execute_command!("brew remove postgresql")
      say_ok("   Uninstallation complete!")
    when :linux
      execute_command!("sudo apt-get -y --purge remove postgresql postgresql-contrib libpq-dev")
      execute_command!("sudo apt-get -y autoremove")
      say_ok("   Uninstallation complete!")
    else
      notify_package_unavailable!
    end
  else
    notify_package_missing!
  end
end
upgrade() click to toggle source
# File lib/active_scripts/packages/postgresql.rb, line 31
def upgrade
  if package_installed?(includes: "postgresql")
    case $operating_system
    when :macosx
      output = execute_command!("brew upgrade postgresql")
      say_warning("   [!] #{output.squish}") unless option_dry_run? || package_output?(output, includes: "Error:")
      say_ok("   Upgrade complete!")
    when :linux
      execute_command!("sudo apt-get -y upgrade postgresql postgresql-contrib libpq-dev")
      say_ok("   Upgrade complete!")
    else
      notify_package_unavailable!
    end
  else
    notify_package_missing!
  end
end