我无法检测到这是启动服务器实例后的第一次部署尝试。我只需要第一次运行命令rake db:seed
来设置数据库中的默认用户和其他详细信息。我不知道这是否可能。
有人可以帮我吗
我无法检测到这是启动服务器实例后的第一次部署尝试。我只需要第一次运行命令rake db:seed
来设置数据库中的默认用户和其他详细信息。我不知道这是否可能。
有人可以帮我吗
找出答案的最佳方法是--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
有几种方法可以做到这一点。
最简单的方法是执行此操作db/seeds.rb
并查询数据是否已经存在,否则在运行时会被覆盖。
如果这样做了,您可以rake db:seed
在部署挂钩中运行。您可以在此处找到有关部署挂钩的文档:https: //support.cloud.engineyard.com/hc/en-us/articles/205407008-Use-Ruby-Deploy-Hooks