I
I
IlyaMalyukov2020-12-19 23:06:30
PostgreSQL
IlyaMalyukov, 2020-12-19 23:06:30

Syntax error during migration. How to fix?

Forgot to add the date of birth field to the registration form
Created a new migration

class AddBirthdayColumnToUsers < ActiveRecord::Migration[6.0]
  def change
    add_column table_name :users, column_name :birthday, type :string
  end
end


I write in the console rake db:migrate
I get an error:
syntax error, unexpected symbol literal, expecting `do' or '{' or '('

So far I could not figure it out myself, so I decided to ask here

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IlyaMalyukov, 2020-12-20
@IlyaMalyukov

I wrote like this and it all worked, but why it didn’t work before and why there was such an error still didn’t understand

class AddBirthdayColumnToUsers < ActiveRecord::Migration[6.0]
  def change
    add_column  :users, :birthday, :date
  end
end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question