How to add a new column in an existing table in Rails 5? How to add a new column in an existing table in Rails 5? ruby ruby

How to add a new column in an existing table in Rails 5?


You forgot to add datatype, below is the updated migration.

class ChangeJobsTable < ActiveRecord::Migration[5.0]  def change    add_column :jobs, :skills2, :string  endend


You indeed forgot the datatype. You can also do it via the console in the future:

rails g migration AddSkills2ToJobs skills2:string


This worked for me and you can verify after in the schema

rails g migration add_skills2_to_ChangeJobsTable skills2:string

rake db:migrate