Question

I want to get rid of everything I did since my last commit, including the tables I created, so I did

git reset --hard HEAD
git clean -f -d

so this got rid of the migrations I created, but in the schema it looks like the tables are still there. I know I can just create new migrations to drop those tables, but I was just wondering for future references how I could reset to the last commit even on the database level.

Another reason why I would need to delete the tables in the database is because when I try to create migrations(models) to create the exact tables, it gives me an error and says they already exist. So if I were to push this to github and production, it would not create the tables since the migrations don't exist. Thus, I think it is necessary for me to delete the created tables locally through some sort (preferably rolling back), and then re-create the migrations.

(I'm using PostGreSQl)

Was it helpful?

Solution

So I solved this temporarily, but probably not the most ideal way to do it.. I just created migrations to remove the tables, ran rake db:migrate, and then deleted the migrations. So this way it's like it never happened.

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