Index on multiple columns in Ruby on Rails

后端 未结 2 1382
感动是毒
感动是毒 2020-12-04 07:07

I\'m implementing functionality to track which articles a user has read.

  create_table \"article\", :force => true do |t|
    t.string   \"title\"
    t.         


        
2条回答
  •  情歌与酒
    2020-12-04 07:21

    Just a warning about checking uniqueness at validation time vs. on index: the latter is done by database while the primer is done by the model. Since there might be several concurrent instances of a model running at the same time, the validation is subject to race conditions, which means it might fail to detect duplicates in some cases (eg. submit twice the same form at the exact same time).

提交回复
热议问题