jdavisclark / mite

schema migrations so easy you already know how to write them. guaranteed.
http://jdc0589.github.io/mite
11 stars 6 forks source link

"Force" option for `mite down` #46

Open notduncansmith opened 10 years ago

notduncansmith commented 10 years ago

There's a situation that I run into a lot:

  1. I create a migration
  2. It turns out that migration should add an extra column
  3. I update the migration's up clause to add the column, and the down column to remove it.
  4. When I run mite down, I get a SQL error telling me that it can't find the column I added (naturally).

We should add a -f or --force flag to mite down to ignore errors and continue to migrate down.

Alternatively, maybe just a mite reset command would be more appropriate? Something that would run all the down migrations (ignoring any errors), truncate the _migrations table, then run the ups? That's what I find myself doing whenever I encounter this problem.

jdavisclark commented 10 years ago

I think I like the --force option if we go for this. But, I think (I could be way wrong) the normal workflow in this situation would be to:

  1. create a migration
  2. realize you need an extra column
  3. step down
  4. add the column to the up + down
  5. step back up

You wouldn't run in to any problems with that process, but it's personal preference.