views:

43

answers:

1

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.

+4  A: 

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.

Justice
+1 Migrations don't have to be restricted to just schema changes.
Shadwell
Correct. In fact, "Migrations are not limited to changing the schema. You can also use them to fix bad data in the database or populate new fields" (http://guides.rubyonrails.org/migrations.html#anatomy-of-a-migration).
Justice