phi*_*lee 82 mysql svn ruby-on-rails
如果多个人正在处理项目并且数据库位置不同(特别是套接字),那么处理Rails database.yml的最佳方法是什么.
Jam*_*sen 160
database.yml
模板文件.如果你在Git:
git mv config/database.yml config/database.yml.example
git commit -m "moved database.yml to an example file"
Run Code Online (Sandbox Code Playgroud)
或者,如果您使用的是Subversion:
svn move config/database.yml config/database.yml.example
svn ci -m "moved database.yml to an example file"
Run Code Online (Sandbox Code Playgroud)
如果你在Git:
cat > .gitignore
config/database.yml
git add .gitignore
git commit -m "ignored database.yml"
Run Code Online (Sandbox Code Playgroud)
如果您使用的是Subversion:
svn propset svn:ignore config "database.yml"
Run Code Online (Sandbox Code Playgroud)
script/plugin install git://github.com/technicalpickles/wheres-your-database-yml-dude
Run Code Online (Sandbox Code Playgroud)
如果他们没有创建自己的本地版本,那么该插件会在任何Rake任务运行之前向开发人员发出警报config/database.yml
.
# in RAILS_ROOT/config/deploy.rb:
after 'deploy:update_code', 'deploy:symlink_db'
namespace :deploy do
desc "Symlinks the database.yml"
task :symlink_db, :roles => :app do
run "ln -nfs #{deploy_to}/shared/config/database.yml #{release_path}/config/database.yml"
end
end
Run Code Online (Sandbox Code Playgroud)
scp config/database.yml user@my_server.com:/path_to_rails_app/shared/config/database.yml
Run Code Online (Sandbox Code Playgroud)
Mar*_*mer 16
在Capistrano 3中,您可以执行以下操作,而不是添加新任务:
set :linked_files, %w{config/database.yml}
Run Code Online (Sandbox Code Playgroud)