1

I'm having trouble migrating my table with Rails. When I run rake db:migrate I get this error.

Error

PG::SyntaxError: ERROR:  syntax error at or near "USING"
LINE 1: ALTER TABLE "assignments" ADD "frequency" integer USING CAST...

Migration

class AddBackFrequeny < ActiveRecord::Migration[5.0]
  def change
    add_column :assignments, :frequency, 'integer USING CAST(frequency AS integer)'
  end
end

I just changed my database to postgresql. maybe somethings there?

1 Answer 1

1

USING is only valid when you alter the DATA TYPE, not when you merely add a column. From \h ALTER

ALTER [ COLUMN ] column_name [ SET DATA ] TYPE data_type [ COLLATE collation ] [ USING expression ]
ADD [ COLUMN ] [ IF NOT EXISTS ] column_name data_type [ COLLATE collation ] [ column_constraint [ ... ] ]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.