[Rails] PG :: DuplicateTable: ERROR: relation "users" How to resolve already exists

PG :: DuplicateTable: ERROR: relation "users" already exists error

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.

Run rails db: migrate: reset

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.

Reference material

[Rails5] PG :: DuplicateTable: Solution for ERROR ~

Recommended Posts

[Rails] PG :: DuplicateTable: ERROR: relation "users" How to resolve already exists
[Rails] How to display error messages individually
How to resolve errors when installing Rails 5.1.3
[Ruby on Rails] How to display error messages
[Rails] How to solve "Uglifier :: Error: Unexpected character'`'"
[Rails] How to get success and error messages
How to write Rails
[Rails] validates How to translate error sentences into Japanese
How to uninstall Rails
How to resolve SSL_connect error in PayPal Ruby SDK
How to resolve Missing Template error when implementing comment function
[Rails] How to display error messages for comment function (for beginners)
[rails] How to post images
[Rails] How to use enum
[Rails] How to install devise
[Rails] How to use enum
How to read rails routes
How to terminate rails server
How to write Rails validation
How to write Rails seed
[Rails] How to use validation
[Rails] How to disable turbolinks
Mysql2 :: Error: Table'relationships' already exists
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
[Rails] How to implement scraping
[Rails] How to make seed
How to write Rails routing
[Rails] How to install simple_calendar
[Rails] How to install reCAPTCHA
[Rails] How to use Scope
[Rails / RSpec] How to deal with element has zero size error
[Rails] How to resolve wrong number of arguments (given 2, expected 0..1) of user_id
[Rails] How to use gem "devise"
How to deploy jQuery on Rails
[Rails] How to install Font Awesome
[Rails] How to use devise (Note)
[Rails] How to use flash messages
[rails] How to display db information
[Rails] How to write in Japanese
[Rails] How to prevent screen transition
How to deploy Bootstrap on Rails
[Rails] How to speed up docker-compose
[Rails] How to add new pages
Rails on Tiles (how to write)
[Rails] How to write exception handling?
[Rails] How to install ImageMagick (RMajick)
How to resolve Mixed Content errors
[Rails] How to use Active Storage
[Technical memo] How to resolve errors
How to introduce jQuery in Rails 6
[Rails] How to implement star rating
How to return Rails API mode to Rails
How to get along with Rails
[Introduction to Rails] How to use render
(Solution) Mysql2 :: Error: Table'users' already exists
How to install Swiper in Rails
How to resolve the error'ActionView :: Template :: Error (The asset "application.css" is not present in the asset pipeline.'" When precompiling Rails assets