[英]Chef: database migration not run in application recipe
I am using application and application_ruby recipes. 我正在使用application和application_ruby食谱。 And I am defining my app like this with migrate '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
However, I don't see any migration running. 但是,我看不到任何迁移正在运行。 I think it is because application_ruby removes it once it is run.
我认为这是因为application_ruby一旦运行就将其删除。 However, in my case, there was a problem in database user credentials and the migration was not successful.
但是,就我而言,数据库用户凭据存在问题,迁移未成功。 Apart from running the migration manually, is there any way I can make it run?
除了手动运行迁移之外,还有什么方法可以使它运行?
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
I think I ran into the same issue, after declaring the migration command, it did work. 我认为在声明了迁移命令后,我确实遇到了同样的问题。 So like this:
像这样:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.