我正在使用application和application_ruby食谱。我正在通过迁移'true'定义我的应用程序:
application 'railsapp' do
owner 'vagrant'
group 'vagrant'
path '/home/vagrant/railsapp'
revision 'master'
repository 'git@github.com:rohshall/railsreadings.git'
migrate true
rails do
bundler true
database do
host 'localhost'
username mysql_connection_info[:username]
password mysql_connection_info[:password]
database 'railsreadings_production'
adapter 'mysql2'
encoding 'utf8'
end
end
unicorn do
worker_processes 2
end
end
但是,我没有看到任何迁移正在运行。我认为这是因为application_ruby一旦运行就会将其删除。但是,就我而言,数据库用户凭据存在问题,并且迁移不成功。除了手动运行迁移之外,还有什么方法可以让它运行吗?
ruby_block "remove_run_migrations" do
block do
if node.role?("#{new_resource.name}_run_migrations")
Chef::Log.info("Migrations were run, removing role[#{new_resource.name}_run_migrations]")
node.run_list.remove("role[#{new_resource.name}_run_migrations]")
end
end
end
答案 0 :(得分:1)
我认为我遇到了同样的问题,在宣布迁移命令后,它确实有效。像这样:
application 'railsapp' do
owner 'vagrant'
group 'vagrant'
path '/home/vagrant/railsapp'
revision 'master'
repository 'git@github.com:rohshall/railsreadings.git'
migrate true
migration_command "bundle exec rake db:migrate"
rails do
bundler true
database do
host 'localhost'
username mysql_connection_info[:username]
password mysql_connection_info[:password]
database 'railsreadings_production'
adapter 'mysql2'
encoding 'utf8'
end
end
unicorn do
worker_processes 2
end
end