[RUBY] What to check when rails db: migration does not pass

When I created a migration file as usual and tried rails db: migrate, I got the following error. Column user_id on table entries does not match column id on users, which has type bigint(20). To resolve this issue, change the type of the user_id column on entries to be :bigint. (For example t.bigint :user_id).

As instructed, the migration was performed again by specifying bigint as shown below.

class CreateEntries < ActiveRecord::Migration[5.1]


  def change
    create_table :entries do |t|
      t.references :user, foreign_key: true, type: :bigint //Change from integer to bigint
      t.references :room, foreign_key: true
      t.timestamps
    end
  end
end```

 However, a similar error appeared.
 Actually, at this time, three migration files were created at the same time, and an error occurred because the creation date and time of the migration file (room) required to register the above migration file was the last.
 I changed the file name to the creation date and time of the room file, and when I ran rails db: migrate again, it passed without problems.


Recommended Posts

What to check when rails db: migration does not pass
What to do when rails db: seed does not reflect in the database
[Rails] What to do when rails s does not respond or does not stop
What to do when Rails on Docker does not reflect controller changes in the browser
[Rails] What to do if data is not registered in DB
[Rails] [Memo] When to add = to <%%> and when not
[Rails 5] [Turbolinks] What to do when JS does not work due to page transition or browser back
[Rails] Bootstrap form-control does not apply to date_select
What to do when debugging "Source not found"
[Grails] Error occurred running What to do when the Grails CLI does not start
What to do when is invalid because it does not start with a'-'
How to deal with FATAL: role "admin0" does not exist and PG :: ConnectionBad: FATAL: role "admin0" does not exist when executing rails db: create
What to do when JSF tags do not become HTML
What to do when rails creates a 〇〇 2.rb file
When the server does not start with rails s
What to do if the update does not take effect after deploying Rails AWS
[Ruby on Rails] When parameter id acquisition does not work
What to do when Method not found in f: ajax
What to do when you launch an application with rails
# What to do if you accidentally do rails db: migrate: drop
What to do when a could not find driver appears when connecting to a DB in a Docker environment
How to specify db when creating an app with rails
Bluemix Infrastructure VPN does not connect because it does not support NPAPI! What to do when [Mac]
How to get the log when install4j does not start
[Ruby on Rails] Column restrictions when saving to DB (4 representatives)
Pass parameters to Rails link_to
When I run rails: db: migrate, I get "Directly inheriting from ActiveRecord :: Migration is not supported."
What to do when "relation" hibernate_sequence "does not exist" in the ID column of PostgreSQL + JPA
[Rails] What to do when the error No database selected and Unknown database appears in db: migrate
What to do if the app is not created with the latest Rails version installed when rails new
What to do when the changes in the Servlet are not reflected
What I did when the DB did not start with docker-compose up
What I was addicted to when implementing google authentication with rails
Docker test DB does not start
[rails] How to display db information
[Rails] Easy way to check columns
Check the migration status of rails
Rails DB PostgreSQL changed to MySQL
What to do when javax.batch.operations.JobStartException occurs
[Rails] Reflection to db using seeds.rb
What to do if you get an error during rails db: reset
What to do when Blocked Host: "host name" appears in Ruby on Rails
Problem of not being able to db: migrate when adding Sorcery submodules
[Docker] Does not connect to MySQL workbench ... DB container port forwarding settings
[Rails] How to pass validation such as password when executing update action
What to do when "call'Hoge.connection' to establish a connection" appears on rails c
[Rails] What to do when the Refile image is not displayed when writing the processing at the time of Routing Error
[Rails] Video does not play with video_tag
Migration file to add comment to Rails table
What to do when a javax.el.PropertyNotWritableException occurs
JavaScript (vanilla) does not respond in Rails.
How to resolve errors when installing Rails 5.1.3
What to do when undefined method ʻuser_signed_in?'
Story when migration could not be done
[NetBeans] Story when it does not start
What to do when you want to delete a migration file that is "NO FILE"
What to do if ffi installation fails when launching an application in Rails
What to do when ‘Could not find’ in any of the sources appears in the development environment with Docker × Rails × RSpec
What to do if you get an error saying "Could not find a JavaScript runtime." When starting rails server