Home>
I tried to migrate the users table with the rails db: migrate command, but I got an error saying that it had already been created.
However, when I checked the status, it remained down. I would appreciate it if you could teach me how to migrate normally.
Terminal
rails db: migrate
== 20201204122031 DeviseCreateUsers: migrating ================================
--create_table (: users)
rails aborted!
StandardError: An error has occurred, all later migrations canceled:
Mysql2 :: Error: Table'users' already exists
/Users/nishio/projects/furima-31536/db/migrate/20201204122031_devise_create_users.rb:5:in `change'
/ Users/nishio/projects/furima-31536/bin/rails: 9: in `<top (required)>'
/ Users/nishio/projects/furima-31536/bin/spring: 15: in `<top (required)>'
bin/rails: 3: in `load'
bin/rails: 3: in `<main>'
Caused by:
ActiveRecord :: StatementInvalid: Mysql2 :: Error: Table'users' already exists
/Users/nishio/projects/furima-31536/db/migrate/20201204122031_devise_create_users.rb:5:in `change'
/ Users/nishio/projects/furima-31536/bin/rails: 9: in `<top (required)>'
/ Users/nishio/projects/furima-31536/bin/spring: 15: in `<top (required)>'
bin/rails: 3: in `load'
bin/rails: 3: in `<main>'
Caused by:
Mysql2 :: Error: Table'users' already exists
/Users/nishio/projects/furima-31536/db/migrate/20201204122031_devise_create_users.rb:5:in `change'
/ Users/nishio/projects/furima-31536/bin/rails: 9: in `<top (required)>'
/ Users/nishio/projects/furima-31536/bin/spring: 15: in `<top (required)>'
bin/rails: 3: in `load'
bin/rails: 3: in `<main>'
Tasks: TOP =>db: migrate
(See full trace by running task with --trace)
database: furima_31536_development
Status Migration ID Migration Name
--------------------------------------------------
up 000 ********** NO FILE **********
down 20201204122031 Devise create users
What I tried
-The bundle exec rake db: migrate: up 20201204122031 command tried to bring a specific file up.
-Try to lower unnecessary files with bundle exec rake db: migrate: down 000.
-Reset with rails db: reset.
-
Answer # 1
-
Answer # 2
Perhaps users are created by the previously existing migratin, which is nofile.
If you have only one migratin, drop db and cerate
Related articles
- ruby on rails - about rails create action
- ruby - [rails] about partial templates
- about description of manifest file of ruby on rails
- ruby - the error in rails g migration cannot be resolved
- ruby on rails 6 - about rails error "wrong number of arguments (given 1, expected 0)"
- ruby - about accelerating heroku's rails app
- ruby on rails 5 - about lint/syntax error of rubocop
- ruby on rails - about deploying apps using s3 function
- ruby on rails - about aws environment variables
- ruby on rails - vuejs cannot find element: app error
- ruby on rails - about saving comments
- ruby on rails - about request spec of rspec about test code at login
- ruby on rails - about image posting page argumenterror
- ruby on rails - rails render: about the matter that the url after new is different
- ruby - about the delete function in rails
- ruby on rails - about the error when trying to implement jquery with rails ($is not defined;please fix or add/* global * /)
- ruby - about rails routing
- ruby on rails - cannot start unicorn cannot load `railsconfigactive_storageservice`
- ruby on rails - about rails composite indexes
Trends
- python - you may need to restart the kernel to use updated packages error
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to check the type of a shell script variable
- i want to call a child component method from a parent in vuejs
in database.yml
When I changed utf8mb4 to utf8, I was able to migrate.