简体   繁体   English

Rails:运行迁移等rake任务

[英]Rails: run rake tasks like migrations

My dev team needs to more precisely run rake tasks. 我的开发团队需要更精确地执行rake任务。 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. 我们喜欢迁移如何使用db表进行日志记录。 Is there a similar tool for rake tasks? 是否有类似的工具用于rake任务? Can we hack Rails'/ActiveRecord's migrations system for rake tasks? 我们可以破解Rails'/ ActiveRecord的rake任务迁移系统吗?

We'd prefer not to mix db-related migrations with rake tasks, so any solution that explicitly keeps these separate would be great. 我们不希望将与数据库相关的迁移与rake任务混合在一起,因此任何明确保持这些迁移的解决方案都会很棒。

Thanks. 谢谢。

need to be only run once after a specific code change 只需在特定代码更改后运行一次

update certain existing users records 更新某些现有用户记录

These are migrations. 这些是迁移。 Use migrations. 使用迁移。 Unless there's some additional constraints you didn't mention, using anything but migrations would be a hack. 除非你没有提到一些额外的限制,否则使用除迁移之外的任何东西都是黑客攻击。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM