AdamNYC
AdamNYC

Reputation: 20415

deleted migration file keeps coming back Rails 3

I have 2 versions of the same migration (bad habit, I know). I deleted old version many times, but after restarting my project (or do something with it, like rake db:test:prepare), the file shows up in my migrate folder. When I run rake db:migrate, it will complain about multiple migrations with the same name.

How can I delete a migration file completely? Is there a registry that I need to remove to prevent it from coming back?

Upvotes: 0

Views: 1143

Answers (2)

jimworm
jimworm

Reputation: 2741

git add only adds new and changed files, it doesn't remove deleted ones. To delete:

git rm db/migrate/<filename>

or if you have already deleted it from the filesystem:

git add -u

Upvotes: 1

Dave Newton
Dave Newton

Reputation: 160170

Are you updating from a repo? I don't see how the original file could be restored otherwise.

You can also delete the entry from the schema_migration table, but that just tracks if it's been run or not (IIRC).

Upvotes: 2

Related Questions