2015-05-29 42 views

回答

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 deployenter image description here

-1

有幾種方法可以做到這一點。

最簡單的方法是在db/seeds.rb中執行此操作,並查詢數據是否已存在,否則在運行時將被覆蓋。

如果已完成,您可以在部署鉤子中運行rake db:seed。 您可以在這裏部署掛鉤找到文檔:https://support.cloud.engineyard.com/hc/en-us/articles/205407008-Use-Ruby-Deploy-Hooks

+0

其實我知道直播。我想知道如果我能檢測如果這個部署嘗試是第一個部署,那麼在部署鉤子內部,這樣只有在需要#bastilian時纔會進行播種 – illusionist

相關問題