[RUBY] About ActiveRecord :: PendingMigrationError

When accessing the URL http: // localhost: 3000/rails/actions ActiveRecord :: PendingMigrationError Is displayed When you press "Perform pending migration" on the page StandardError Is displayed

■ Hypothesis ActiveRecord :: PendingMigrationError Try to search on the internet https://qiita.com/KONTA2019/items/0444ae3b8c8936a56ee0 Pay attention to the cause 2 of the error on this page

Mysql2 :: Error: Table'users' already exists Because there is I updated the migration file and rails db: migrated while migration was completed (up) Isn't that the problem?

■ Verification ・ $ Rails db: migrate: reset And bring the migration up again → No change

・ $ Rails db: rollback  $ rails db:migrate , Remand the migration, and migrate again → No change

Screenshot of the following error https://gyazo.com/23116ecff6eb24e08bb514bd3ce7df76



result The cause is that migtate/create_users.rb is duplicated. This error is resolved by deleting one of the files. The hypothesis is that users.rb can't be overwritten, so I thought it would be cured by sending it back and then migrating again. It wasn't the cause because it was already created and the file was duplicated. Other initial setting mistakes. I made a mistake in a smaller part, so I fixed it (I got it).

Reflection I couldn't ask why the files were duplicated, but I think it was probably because I did rails db: migrate without rolling back. Be careful when performing migration. It is important to pay attention to careless mistakes. Below, the modified screenshot https://gyazo.com/e710ebcf079d3f2fbf1be35ae3dfaa62

Recommended Posts

About ActiveRecord :: PendingMigrationError
About ActiveRecord default_timezone
About =
About method.invoke
About Kotlin
About attr_accessor
About Hinemos
About inheritance
About Docker
About Rails 6
About form_for
About Spring ③
About enum
About polymorphism
About Optional
About hashes
About JitPack
About Dockerfile
About this ()
About devise
About encapsulation
About Docker
About active_hash
About static
About exceptions
About scope
[Maven] About Maven
[Rails] ActiveRecord
[Rails / ActiveRecord] About the difference between create and create!