What are Rails Fixtures Good for Anyway?

(This is the second of three posts on Rails fixtures)

I like using fixtures for setting up a development environment. Applications need data in the db to function so what most teams do is pass around a database, or two, or five. A new person joins the project and he/she gets a dump from one of the devs, imports it and goes to work. What happens when you screw up your db by:
  • Running a bad migration
  • Importing a crap load of data for a task (I remember once filling up a db with all movies playing in North America) but later you don't need it.
  • Doing something dumb. (my personal favorite)

Well, you need to get somebody else's db. Which maybe in a bad state and it definitely doesn't have the same data you're used to because they've been changing it a lot.

But if you have a bunch of fixtures checked in to source control, you can always go back to a base state. Anytime something is acting wacky and you think it might be a data problem (which happens more and more as the app gets older) wiping the db is simple and easy. Also, everyone has the same data so you can collaborate easier.


Next: How to migrate fixtures.

Comments

Popular posts from this blog

Point Inside a Polygon in Ruby

What's a Good Flog Score?

SICP Wasn’t Written for You