0

I'm seeing this error when I try a rake db:migrate:

/db/migrate/20180124161533_a_dd_uid_to_appuser_and_response.rb:22: syntax error, unexpected '\n', expecting => 

From what I can see, I don't see any new lines in the migration file though:

class ADdUidToAppuserAndResponse < ActiveRecord::Migration disable_ddl_transaction! def change add_column :appusers, :archived, :boolean, algorithm: :concurrently, if !column_exists?(:appusers, :archived) add_column :responses, :archived, :boolean, algorithm: :concurrently, if !column_exists?(:responses, :archived) add_column :appuser_rewards, :archived, :boolean, algorithm: :concurrently, if !column_exists?(:appuser_rewards, :archived) add_column :appusers, :last_checked_campaigns_at, :datetime, algorithm: :concurrently, if !column_exists?(:appusers, :last_checked_campaigns_at) add_column :appusers, :last_checked_for_available_campaigns_at, :datetime, algorithm: :concurrently, if !column_exists?(:appusers, :last_checked_for_available_campaigns_at) add_column :appusers, :uid, :uuid, default: 'uuid_generate_v4()', algorithm: :concurrently, if !column_exists?(:appusers, :uid) add_column :responses, :uid, :uuid, default: 'uuid_generate_v4()', algorithm: :concurrently, if !column_exists?(:responses, :uid) add_column :appuser_rewards, :uuid, :uuid, default: 'uuid_generate_v4()', algorithm: :concurrently, if !column_exists?(:appusers, :uuid) add_index :appusers, :uid, algorithm: :concurrently, where: "archived = false", if !index_exists?(:appusers, :uid) add_index :responses, :uid, algorithm: :concurrently, where: "archived = false", if !index_exists?(:responses, :uid) end end 

Any idea what the problem is?

2
  • 2
    You have erroneous trailing commas on all your add_column and add_index calls. m x, if ... tells Ruby that the if is an expression that will produce another argument to m, m x if ... is m(x) with a postfix conditional. Commented Jan 28, 2018 at 23:10
  • Would you mind throwing an example in as an answer? I didn't write this migration :) Commented Jan 28, 2018 at 23:44

1 Answer 1

1

Here is the example how you should modify your code. Just remove , before if statement for all lines. So for example the line:

add_column :appusers, :archived, :boolean, algorithm: :concurrently, if !column_exists?(:appusers, :archived) 

is supposed to be:

add_column :appusers, :archived, :boolean, algorithm: :concurrently if !column_exists?(:appusers, :archived) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.