You may get an error with rails db: migrate. In my case, I get some kind of error for some reason, so I tried to find out how to deal with it. (I myself am a beginner in both ruby and rails. I am writing this article for my learning, hoping that it will be helpful for beginners.)
== 20201011010946 CreatePosts: migrating ====================================== -- create_table(:posts) rails aborted! StandardError: An error has occurred, this and all later migrations canceled: PG::DuplicateTable: ERROR: relation "posts" already exists (to be continued)
Regarding this Standard Error, migrate was executed, but an error occurred during execution for some reason, and the table is created but the migrate situation is treated as unexecuted.
In other words, I think it feels like it was interrupted by a small error on the system side.
However, the error statement says /post_bootstrap_app/db/migrate/20201011010946_create_posts.rb:3:in `change'as if there was a mistake there, saying," I'm messing around with that? It becomes a state and is confused for a moment.
rails db:migrate:reset * Reset the execution of migrate once rails db:migrate * Rails db again:Run migrate
I did some research on how to deal with it, but I decided that the interrupted migrate was not reset once, and if I try again with migrate, it will work, so I actually tried this method. It was.
As a result, I succeeded in db: migrate as if nothing had happened!
I think that some beginners are confused when an error occurs when creating a salty database, saying "Why is an error even though I haven't written much yet?".
However, this simple method may solve the problem, so if you are in trouble, please try it. I hope you find it helpful.