[英]Best way to run data script on heroku console?
我正在嘗試將PostgreSQL數據從json列移動到同一表中的其他列。
我如何有效地做到這一點? 我的heroku控制台在10-20分鍾后死亡,我有100,000多個記錄需要更新。
Ticket.where(payment_type: nil).find_each(batch_size: 1000) do |ticket|
ticket.update_attributes(payment_type: ticket.data['_embedded']['payments'][0]['_embedded']['name']) if ticket.data['_embedded']['payments'].present?
end
嘗試將其轉換為rake任務,然后使用:
heroku run:detached rake <yourtaskname>
約翰。
https://devcenter.heroku.com/articles/one-off-dynos#running-tasks-in-background
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.