0

我无法检测到这是启动服务器实例后的第一次部署尝试。我只需要第一次运行命令rake db:seed来设置数据库中的默认用户和其他详细信息。我不知道这是否可能。

有人可以帮我吗

4

2 回答 2

1

找出答案的最佳方法是--extra-deploy-hook-options在运行部署命令时发送并检查after_migrate.rb是否config[:initial]存在。该命令看起来像

  ey deploy -e myapp_staging --config=initial:true

after_migrate.rb 钩子看起来像:

on_app_servers do
  if config[:initial] == 'true'
    $stderr.puts "Seeding the data"
    run "cd #{config.release_path}"
    run "bundle exec rake db:seed"
  else
    $stderr.puts "Skipping the Seeding process"
   end
end

了解更多信息ey help deploy在此处输入图像描述

于 2015-06-11T04:52:36.643 回答
-1

有几种方法可以做到这一点。

最简单的方法是执行此操作db/seeds.rb并查询数据是否已经存在,否则在运行时会被覆盖。

如果这样做了,您可以rake db:seed在部署挂钩中运行。您可以在此处找到有关部署挂钩的文档:https: //support.cloud.engineyard.com/hc/en-us/articles/205407008-Use-Ruby-Deploy-Hooks

于 2015-06-03T11:55:36.107 回答