--Team development beginner --People who are having trouble with database-related errors when developing apps with Rails --Git beginner
$ rails -v
Rails 6.0.3.1
$ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
$ git --version
git version 2.27.0
$ mysql --version
mysql Ver 14.14 Distrib 5.7.29, for osx10.15 (x86_64) using EditLine wrapper
--I wanted to move to another member's branch and check the behavior for review, but I got an error when starting the server. ――It seems that there is a database-related error.
ActiveRecord::PendingMigrationError
https://qiita.com/KONTA2019/items/0444ae3b8c8936a56ee0
Refer to the above and solve the problem. By the way, I
$ rails db:migrate
Solved with.
But after that, I got the following error. .. ..
Multiple migrations have the name ~~~.
In conclusion, ~~~ will contain ** migration file name **.
In the case of I,
Multiple migrations have the name CreateUsers.
And when I check my migration file,
$ rails db:migrate:status
Status Migration ID Migration Name
--------------------------------------------------
up 20200618162841 Create tweetposts
up 20200620004226 Change tweetposts to tweets
down 20200621075518 Create posts
down 20200623102444 Change posts to chats
down 20200627042358 Create users
up 20200627080839 Create users
up 20200627083356 Add column to users
down 20200627220915 Change datatype content of chats
up 20200703201452 ********** NO FILE **********
down 20200710035709 Add user id to tweets
There was a CreateUsers file.
I think you can guess it well, but from the content of the error statement, it is presumed that "** There is a migration file with the same name, so I do not know which one to refer to when building the database **". I can do it.
So
down 20200627042358 Create users
Delete this file and
$ rails db:migrate
$ bundle exec rails s
You have now started the server!
Of the migration file
up 20200703201452 ********** no file **********
You're curious, right? ??
This is a mysterious phenomenon that the database is built with reference to the missing files, so I would like to delete it.
The cause of this is that the migration file was deleted before the migration was down, but the solution is as follows.
https://qiita.com/beanbeenzou/items/e8886071ab1e1cf7a9c0