[In team development] Error when moving to another member's branch and doing rails s [Rails]

Reference target person

--Team development beginner --People who are having trouble with database-related errors when developing apps with Rails --Git beginner

environment

$ 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

Status

--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!

By the way, ...

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

Recommended Posts

[In team development] Error when moving to another member's branch and doing rails s [Rails]
[Programming beginner] What to do when rails s becomes an error in the local development environment
[Rails] What to do when the error No database selected and Unknown database appears in db: migrate
Trial and error to display national holidays in Android app development. Part 2
What to do and how to install when an error occurs in DXRuby 1.4.7
Trial and error to display national holidays in Android application development. Part 1
[Rails] [Memo] When to add = to <%%> and when not
[rails s error] md5.bundle and mysql installation error
Summary when trying to use Solr in Java and getting an error (Solr 6.x)
Articles and books that engineers who were doing web system development in Java referred to when starting PHP and Laravel
Error in bundle install when running rails new
[Rails] Solution when migration error occurs in acts-as-taggable-on
[Rails] How to get success and error messages
What to do when Address already in use is displayed after executing rails s
Library not loaded when trying to upgrade the version of ruby and rails s
What to do when an error occurs in rails db: migrate ((StandardError: An error has occurred, this and all later migrations canceled :))
What to do when an error (StandardError: An error has occurred, this and all later migrations canceled:) appears in rails db: migrate
Change date and time to Japanese notation in Rails
[Rails] About error resolution when installing devise and activeadmin
How to solve the problem when the value is not sent when the form is disabled in rails and sent