Add unique index on DB level for fields where the model has :validates_uniqueness_of ... #191

Closed
jerboaa opened this Issue Nov 21, 2010 · 5 comments

Comments

Projects
None yet
4 participants
@jerboaa
Member

jerboaa commented Nov 21, 2010

Due to possible races which can happen for MarkUs installs having several clustered mongrels Rails' :validates_uniqueness_of is not enough. We also need unique indexes on DB level to alleviate this. More information here:
http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html (see the "Concurrency and integrity" section).

We need to go over our models and add those indexes where appropriate.

@mina

This comment has been minimized.

Show comment
Hide comment
@mina

mina Aug 18, 2012

Contributor

which tables do we want these on?

Contributor

mina commented Aug 18, 2012

which tables do we want these on?

@ghost ghost assigned ghigt Jun 8, 2013

benjaminvialle added a commit that referenced this issue Jun 11, 2013

Merge pull request #1114 from GhiGt/issue-191
Closes #191: add unique index on DB level
@ghigt

This comment has been minimized.

Show comment
Hide comment
@ghigt

ghigt Jun 12, 2013

Member

@benjaminvialle

There is an error in what I've done, MySQL produces an error referenced here: http://stackoverflow.com/questions/1827063/mysql-error-key-specification-without-a-key-length

Sorry, I only checked on SQLite.

Is it better to remove this index or edit the data type TEXT ?

Member

ghigt commented Jun 12, 2013

@benjaminvialle

There is an error in what I've done, MySQL produces an error referenced here: http://stackoverflow.com/questions/1827063/mysql-error-key-specification-without-a-key-length

Sorry, I only checked on SQLite.

Is it better to remove this index or edit the data type TEXT ?

@benjaminvialle

This comment has been minimized.

Show comment
Hide comment
@benjaminvialle

benjaminvialle Jun 12, 2013

Member

Is the data type TEXT really necessary? What about a STRING type?

Member

benjaminvialle commented Jun 12, 2013

Is the data type TEXT really necessary? What about a STRING type?

@jerboaa

This comment has been minimized.

Show comment
Hide comment
@jerboaa

jerboaa Jun 12, 2013

Member

AFAIK, annotation categories are those "canned" annotations from which graders can select from. A limit of 255 chars seems fairly restrictive. Is it worth the unique index in this case?

Member

jerboaa commented Jun 12, 2013

AFAIK, annotation categories are those "canned" annotations from which graders can select from. A limit of 255 chars seems fairly restrictive. Is it worth the unique index in this case?

@ghigt

This comment has been minimized.

Show comment
Hide comment
@ghigt

ghigt Jun 14, 2013

Member

@jerboaa I agree, it's not necessary. I removed this migration in a new PR.

Member

ghigt commented Jun 14, 2013

@jerboaa I agree, it's not necessary. I removed this migration in a new PR.

benjaminvialle added a commit that referenced this issue Jul 2, 2013

Merge pull request #1121 from GhiGt/issue-191
Closes #191: Remove index in annotation_categories
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment