views:

14

answers:

1

I've been working on a rails project, in which I need to firstly seed the database and then update the data periodically.

The unfortunate problem is that I seem to want to update the same set of data multiple times. Hence I would like to use the same migration name...but the rails generator seems to complain about the naming.

This leads me to a couple of questions.

Should I even be using migrations to update data in my db or is there an alternative? How do I get around the naming problems, my assumption was that the timestamp that prepends itself to the migration name would be an adequate differentiating factor?

Thanks

A: 

A while back developers used the migration for seeding data. Such was the importance of this need as a core feature and the perceived uncleanliness of this approach, Rails 2.3.4 introduced a dedicated rake task for doing this.

This is now best practice. See this post and this screencast for more info.

For periodic db updating you can add a custom rake task to lib/tasks which works well in my experience.

bjg