theres no reason to be writing raw sql ere. also, this isn't a rake task. google or ask your colleagues on how to write a rake task!