Jwan622
Jwan622

Reputation: 11659

Problems migrating on mysql2. Rails

I'm running bundle exec rake db:create and then bundle exec rake db:migrate` and I run into this error when migrating:

 bundle exec rake db:migrate
== 20110125192211 InitialDigitizationWork: migrating ==========================
-- create_table(:digitizations)
   -> 0.0170s
-- add_index(:digitizations, :submission_code, {:unique=>true})
   -> 0.0156s
-- create_table(:digitized_pieces)
   -> 0.0180s
-- add_index(:digitized_pieces, :digitization_id)
   -> 0.0113s
-- create_table(:digitized_views)
   -> 0.0235s
-- add_index(:digitized_views, :digitized_piece_id, {:null=>false})
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

Unknown key: :null. Valid keys are: :unique, :order, :name, :where, :length, :internal, :using, :algorithm,

It's my first time using Mysql (I'm used to Postgresql) I seem to have Mysql:

 mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 5.7.20 Homebrew

This is my database.yml file:

development:
  adapter: mysql2
  database: arthouse_dev
  username: root
  password:
  host: localhost
  port: 3306
  #socket: /tmp/mysql.sock

legacy_development:
  adapter: mysql2
  database: arthouse_leg_development
  username: root
  password:
  host: localhost
  port: 3306

Upvotes: 0

Views: 75

Answers (2)

dB.
dB.

Reputation: 4770

I believe this is just a bug, you cannot have null: false for an index.

Upvotes: 1

Cyzanfar
Cyzanfar

Reputation: 7146

You cannot add a default: null constrain to an index, the error you see states that explicitly:

Unknown key: :null. Valid keys are: :unique, :order, :name, :where, :length, :internal, :using, :algorithm

Remove the default null on those indexes and you should be fine.

Upvotes: 0

Related Questions