문제

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)

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top