0

Trying to get an app up and running on a new machine. May be using a slightly updated version of Ruby (2.3.4 vs 2.3.1) and the Rails version is 5.1.3.

Here's the migration:

class AddDragAndDropRules < ActiveRecord::Migration[5.0]
  def change
    add_column :products, :fixture_location, :string, default: "none"
    add_column :products, :attaches_to, :uuid, array: true, default: []
  end
end

The issue during rails db:migrate.

Error:

== 20160928162420 AddDragAndDropRules: migrating ==============================
-- add_column(:products, :fixture_location, :string, {:default=>"none"})
   -> 0.0142s
-- add_column(:products, :attaches_to, :uuid, {:array=>true, :default=>[]})
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

no implicit conversion of Array into String
/Users/mike/api/db/migrate/20160928162420_add_drag_and_drop_rules.rb:4:in `change'
bin/rails:9:in `require'
bin/rails:9:in `<main>'
TypeError: no implicit conversion of Array into String
/Users/mike/api/db/migrate/20160928162420_add_drag_and_drop_rules.rb:4:in `change'
bin/rails:9:in `require'
bin/rails:9:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Anyone able to spot the error?

0

1 Answer 1

1

In case this helps anyone else - the project was upgraded to Rails 5.1.3 at some point which is causing UUID array migrations to fail due to a bug.

Issue is here (https://github.com/rails/rails/issues/30539) and workaround in 5.1.2-5.1.3 is to do this:

add_column :products, :attaches_to, :uuid, array: true, default: '{}'

Should be fixed in 5.1.4 and above.

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.