Fake a composite primary key? Rails

后端 未结 3 1432
刺人心
刺人心 2021-02-09 15:59

I have a table with id|patient_id|client_id|active. A record is unique by patient_id, client_id meaning there should only be one enrollment per patient per client. Normally I wo

3条回答
  •  [愿得一人]
    2021-02-09 16:36

    Add a UNIQUE constraint to your table across the two columns. Here's a reference for MySQL http://dev.mysql.com/doc/refman/5.0/en/constraint-primary-key.html

提交回复
热议问题