Question

As a direct result of my own stupidity I have managed to somehow get my database in a broken state and can't figure out how to fix it.

The problem started with a typo in one of my db migrations. I was adding a column and mis-spelled the name of the table that I wanted to add the column to. I ran 'rake db:migrate' and it failed. So I went and fixed the typo and ran 'rake db:migrate' again but nothing happened. So thinking that perhaps rails thought it had already done the migration, I ran 'rake db:rollback', which appeared to finally knacker things as it dropped the table I was trying to add the column to.

The end result of all this is that the version of my db is now out of sync with what rails thinks it is. I've tried using 'rake db:migrate:up' and 'rake db:migrate:down' (with version numbers) but this hasn't helped. Even when I try and explicitly run the migration that created the problem table, nothing happens (tho if I run the 'down' version it tells me it can't drop the table'). I know I could just access the db directly and patch up the problem table but I figured it would be good to find out if there is a 'proper' solution to this problem.

Many thanks

Was it helpful?

Solution

OTHER TIPS

rake db:reset

and for some reason there's a 30-char minimum for posting an answer :-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top