Skip to content

Instantly share code, notes, and snippets.

@miry
Created September 25, 2013 14:07
Show Gist options
  • Save miry/6700162 to your computer and use it in GitHub Desktop.
Save miry/6700162 to your computer and use it in GitHub Desktop.
namespace :deploy do
namespace :check do
task :linked_files => 'config/database.yml'
end
end
remote_file 'config/database.yml' => '/tmp/database.yml', roles: :app
file '/tmp/database.yml' do |t|
default_template = <<-EOF
base: &base
adapter: sqlite3
timeout: 5000
development:
database: #{shared_path}/db/development.sqlite3
<<: *base
test:
database: #{shared_path}/db/test.sqlite3
<<: *base
production:
database: #{shared_path}/db/production.sqlite3
<<: *base
EOF
location = fetch(:template_dir, 'lib/capistrano/tasks/templates') + '/database.yml.erb'
template = File.file?(location) ? File.read(location) : default_template
config = ERB.new(template)
File.open t.name, 'w' do |f|
f.puts config.result(binding)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment