Herkoku 上的 SQL 内务管理任务
我不知道如何做到这一点...
我有一个包含消息和类别表的数据库。
类别表有一个字段,其中包含与其相关的消息数。
然而,有时我需要停用(active = 0)一条消息,目前这不会更新类别表...我将在最后实现这一点,但目前我只想运行一个脚本每天都会遍历所有类别、统计消息并更新字段。
这样做的最好方法是什么?
预先感
谢克里斯
I'm not sure how to do this...
I have a database which contains a messages and categories tables.
The categories table has a field which has a count of the number of messages related to it.
Sometimes however I need to deactivate (active = 0) a message, at the moment this doesn't then update the category table... I will implement this is in the end but for the time I would just like to run a script perhaps daily that goes through all the categories, counts up the messages and updates the field.
What the best way of doing this?
Thanks in advance
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您愿意手动执行此操作,则可以创建 Rake 任务。推送到 Heroku,然后使用“heroku rake”执行。
您还可以使用Heroku 支持的delayed_job。然而,这确实会花费您每小时 0.05 美元。考虑到它不会经常运行或运行很长时间,可能会相当便宜。
我完成此操作的唯一其他方法是制作一个包装逻辑的控制器,然后调用它。您可以使用众多不同的 ping 服务之一来触发调用(这些服务通常设置为请求站点中的页面)或设置 cron 来使用 wget 或curl 来发出请求。
If you are happy to do this manually you can create a Rake task. Push to Heroku, then execute using "heroku rake".
You could also use delayed_job, which Heroku supports. This does however cost you money $0.05 an hour. Given that it won't run very often or for very long, might be quite cheap.
The only other way I have done this stuff is to make a controller that wraps the logic and then call this. You can use one of the many and various ping services to trigger the call (these services are generally setup to request a page in your site) or setup a cron to use wget or curl to make the request.