I got an error when trying to migrate a database in Rails. The content of the error was "The users table already exists!". I didn't understand it well at first, so I deleted the migration file and I tried to create it again, but I got the same error again.
As a result of searching the error content, it seems that it is best to reset it, so
rails db:migrate:reset
Execute.
Dropped database 'rspec_sample_development'
Dropped database 'rspec_sample_test'
Created database 'rspec_sample_development'
Created database 'rspec_sample_test'
== 20210103133942 CreateUsers: migrating ======================================
-- create_table(:users)
-> 0.0317s
-- add_index(:users, :email, {:unique=>true})
-> 0.0051s
== 20210103133942 CreateUsers: migrated (0.0371s) =============================
A display like this appeared, and the database was successfully reset.
Again, I was able to reflect the database with rails db: migrate
.
[Rails5] PG :: DuplicateTable: Solution for ERROR ~
Recommended Posts