Sha256: 0d1195db58db5127062988cfba6e3114da284b99007d5da293d95268119417f3

Contents?: true

Size: 1.83 KB

Versions: 22

Compression:

Stored size: 1.83 KB

Contents

namespace :deploy do

  namespace :db do

    desc <<-DESC
      Creates the database.yml configuration file in shared path.

      By default, this task uses a template unless a template \
      called database.yml.erb is found either is :template_dir \
      or /config/deploy folders. The default template matches \
      the template for config/database.yml file shipped with Rails.

      When this recipe is loaded, db:setup is automatically configured \
      to be invoked after deploy:setup. You can skip this task setting \
      the variable :skip_db_setup to true. This is especially useful \ 
      if you are using this recipe in combination with \
      capistrano-ext/multistaging to avoid multiple db:setup calls \ 
      when running deploy:setup for all stages one by one.
    DESC
    task :setup, :except => { :no_release => true } do

      default_template = <<-EOF
login: &login
adapter: postgresql
username: #{application}

production:
<<: *login
database: #{application}

development:
<<: *login
database: #{application}_dev

test: &test
<<: *login
database: #{application}_test

cucumber:
<<: *test
EOF
      location = fetch(:template_dir, "config/deploy") + '/database.yml.erb'
      template = File.file?(location) ? File.read(location) : default_template

      config = ERB.new(template)

      run "mkdir -p #{shared_path}/config" 
      put config.result(binding), "#{shared_path}/config/database.yml"
    end

    desc <<-DESC
      [internal] Updates the symlink for database.yml file to the just deployed release.
    DESC
    task :symlink, :except => { :no_release => true } do
      run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" 
    end

  end

  after "deploy:setup",           "deploy:db:setup"   unless fetch(:skip_db_setup, false)
  after "deploy:finalize_update", "deploy:db:symlink"

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
o2h-0.2.1 lib/o2h/recipes/database.rb
o2h-0.2.0 lib/o2h/recipes/database.rb
o2h-0.1.16 lib/o2h/recipes/database.rb
o2h-0.1.15 lib/o2h/recipes/database.rb
o2h-0.1.14 lib/o2h/recipes/database.rb
o2h-0.1.13 lib/o2h/recipes/database.rb
o2h-0.1.12 lib/o2h/recipes/database.rb
o2h-0.1.11 lib/o2h/recipes/database.rb
o2h-0.1.10 lib/o2h/recipes/database.rb
o2h-0.1.9 lib/o2h/recipes/database.rb
o2h-0.1.8 lib/o2h/recipes/database.rb
o2h-0.1.7 lib/o2h/recipes/database.rb
o2h-0.1.6 lib/o2h/recipes/database.rb
o2h-0.1.5 lib/o2h/recipes/database.rb
o2h-0.1.4 lib/o2h/recipes/database.rb
o2h-0.1.3 lib/o2h/recipes/database.rb
o2h-0.1.2 lib/o2h/recipes/database.rb
o2h-0.1.1 lib/o2h/recipes/database.rb
o2h-0.1.0 lib/o2h/recipes/database.rb
o2h-0.0.5 lib/o2h/recipes/database.rb