“MUL”是否可以接受“主键”?

时间:2013-03-13 05:11:40

标签: mysql ruby-on-rails ruby database ruby-on-rails-3

我正在尝试使用ActiveUUID gem来使我的Survey表的主键成为UUID。 (MySQL的)

即使我有:primary_key => true,它仍然因某种原因将其设置为MUL?这是预期的吗?

迁移:

class CreateSurveys < ActiveRecord::Migration
  def change
    create_table :surveys, :id => false do |t|
      t.references :employee, :null => false

      t.uuid :id, :primary_key => true
      t.datetime :expired_at

      t.timestamps
    end
    add_index :surveys, :id
  end
end

型号:survey.rb

class Survey < ActiveRecord::Base

  include ActiveUUID::UUID

  belongs_to :employee

  validates :employee, :presence => true  

end

1 个答案:

答案 0 :(得分:0)

我找到了答案。我需要删除add_index :surveys, :id。显然,主键已经编入索引。修好了