Rails:运行 rake 任务,例如迁移
我的开发团队需要更精确地运行 rake 任务。有些任务只需在特定代码更改后运行一次。不用太具体,这就像在代码中实现新用户的新业务规则后需要更新某些现有用户记录一样。
我们喜欢迁移如何使用数据库表进行日志记录。有类似的用于 rake 任务的工具吗?我们可以破解 Rails/ActiveRecord 的迁移系统来执行 rake 任务吗?
我们不希望将与数据库相关的迁移与 rake 任务混合在一起,因此任何明确将这些任务分开的解决方案都会很棒。
谢谢。
My dev team needs to more precisely run rake tasks. There are certain tasks that need to be only run once after a specific code change. Without getting too specific, it would be like needing to update certain existing users records after a new business rule for new users is implemented in the code.
We like how migrations use a db table for logging. Is there a similar tool for rake tasks? Can we hack Rails'/ActiveRecord's migrations system for rake tasks?
We'd prefer not to mix db-related migrations with rake tasks, so any solution that explicitly keeps these separate would be great.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
后运行一次这些是迁移。使用迁移。除非有一些您没有提到的额外限制,否则使用除迁移之外的任何内容都将是一种黑客行为。
These are migrations. Use migrations. Unless there's some additional constraints you didn't mention, using anything but migrations would be a hack.
我根据您的需要创建了一个 gem:
http://eyaleizenberg .blogspot.co.il/2014/08/how-to-keep-track-of-rails-rake-tasks.html
I created a gem for exactly what you need:
http://eyaleizenberg.blogspot.co.il/2014/08/how-to-keep-track-of-rails-rake-tasks.html