Sha256: ffbbecd011f5ab246df2152264eeaf1c40728990b1481ead52655396fd716ab9

Contents?: true

Size: 1.45 KB

Versions: 10

Compression:

Stored size: 1.45 KB

Contents

set_default(:postgresql_host, "localhost")
set_default(:postgresql_user) { application }
set_default(:postgresql_password) { Capistrano::CLI.password_prompt "PostgreSQL Password: " }
set_default(:postgresql_database) { "#{application}_production" }

namespace :postgresql do
  desc "Install the latest stable release of PostgreSQL."
  task :install, roles: :db, only: {primary: true} do
    run "#{sudo} add-apt-repository ppa:pitti/postgresql --yes"
    run "#{sudo} apt-get -y update"
    run "#{sudo} apt-get -y install postgresql libpq-dev"
  end
  after "deploy:install", "postgresql:install"

  desc "Create a database for this application."
  task :create_database, roles: :db, only: {primary: true} do
    run %Q{#{sudo} -u postgres psql -c "create user #{postgresql_user} with password '#{postgresql_password}';"}
    run %Q{#{sudo} -u postgres psql -c "create database #{postgresql_database} owner #{postgresql_user};"}
  end
  after "deploy:setup", "postgresql:create_database"

  desc "Generate the database.yml configuration file."
  task :setup, roles: :app do
    run "mkdir -p #{shared_path}/config"
    template "postgresql.yml.erb", "#{shared_path}/config/database.yml"
  end
  after "deploy:setup", "postgresql:setup"

  desc "Symlink the database.yml file into latest release"
  task :symlink, roles: :app do
    run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  end
  after "deploy:finalize_update", "postgresql:symlink"
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rail_pass-0.2.0 lib/generators/templates/config/recipes/postgresql.rb
rail_pass-0.1.10 lib/generators/templates/config/recipes/postgresql.rb
rail_pass-0.1.9 lib/generators/templates/config/recipes/postgresql.rb
rail_pass-0.1.8 lib/generators/templates/config/recipes/postgresql.rb
rail_pass-0.1.7 lib/generators/templates/config/recipes/postgresql.rb
rail_pass-0.1.6 lib/generators/templates/config/recipes/postgresql.rb
rail_pass-0.1.5 lib/generators/templates/config/recipes/postgresql.rb
rail_pass-0.1.4 lib/generators/templates/config/recipes/postgresql.rb
rail_pass-0.1.3 lib/generators/templates/config/recipes/postgresql.rb
rail_pass-0.1.1 lib/generators/templates/config/recipes/postgresql.rb