您可以在您的用户/密码中为具有适当权限的用户指定一些migration
连接并运行config/database.yml
RAILS_ENV=migration rake db:migrate
编辑看起来像这样的东西可能会起作用(尽管我从未通过远程连接测试过它,只在本地测试过)。将以下内容添加到您的config/database.yml
.
<%
require 'highline/import'
def request_input(msg, show_input = true)
ask(msg) { |q| q.echo = show_input }
end
%>
migration:
# Other connection information here (host, adapter, etc..)
username: <%= request_input "Username:" %>
password: <%= request_input "Password:", false %>
当你跑
RAILS_ENV=migration rake db:migrate
系统将提示您输入连接的用户名和密码。确保添加
gem 'highline'
到你的Gemfile
.
来源:http ://dzone.com/snippets/request-database