2

我正在使用 application 和 application_ruby 食谱。我正在使用 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

但是,我没有看到任何迁移正在运行。我认为这是因为 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
4

1 回答 1

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
于 2013-08-31T10:04:56.420 回答