在mysql2上迁移的问题。轨道

时间:2017-11-01 22:39:48

标签: mysql ruby-on-rails

我正在运行bundle exec rake db:create然后捆绑exec rake db:migrate`并在迁移时遇到此错误:

 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,

这是我第一次使用Mysql(我习惯使用Postgresql)我似乎有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

这是我的database.yml文件:

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

2 个答案:

答案 0 :(得分:1)

我相信这只是一个错误,不能为索引使用null: false

答案 1 :(得分:0)

您无法向索引添加default: null约束,您看到的错误明确指出:

  

未知密钥:: null。有效密钥是:: unique,:order,:name,:where,   :length,:internal,:using,:algorithm

删除这些索引上的默认null,你应该没问题。