Sha256: c8165c6da88c1af34c51f066bb4a619a6b2e4c88757fcafa0720fe7b3780114d

Contents?: true

Size: 1.96 KB

Versions: 19

Compression:

Stored size: 1.96 KB

Contents

# encoding: utf-8
module MagicRecipes
  module Assets
    def self.load_into(configuration)
      configuration.load do
        
        # code is taken from railscast #337
        
        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"
            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
        
        # eof
        
      end
    end
  end
end

        

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
magic_recipes-0.0.19 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.18 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.17 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.16 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.15 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.14 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.13 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.12 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.11 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.10 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.9 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.8 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.7 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.6 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.5 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.4 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.3 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.2 lib/magic_recipes/postgresql.rb
magic_recipes-0.0.1 lib/magic_recipes/postgresql.rb