hasjob icon indicating copy to clipboard operation
hasjob copied to clipboard

JobApplication needs unique constraint on JobPost+User

Open jace opened this issue 9 years ago • 1 comments

A candidate can apply to a given job only once, and this application is saved in the JobApplication model. However, when the model was originally introduced in 2013, we forgot to add a unique constraint enforcing one-off applications. This is now necessary:

__table_args__ = (db.UniqueConstraint('jobpost_id', 'user_id'),)

There is a twist: our original implementation was also susceptible to the double-click race condition, so the production database has multiple duplicate records. To add this unique constraint, we must necessarily remove these duplicate entries. However, since the JobApplication model also records the employer's response, there is no straightforward way to identify dupes that are safe to delete.

In #226 there's a brief mention of an idea to replace the dual-function JobApplication model with a simpler Message model. That needs elaboration in a separate ticket, but this ticket exists to record a long pending problem, the lack of a unique constraint.

jace avatar Nov 21 '15 06:11 jace

Related: #352.

jace avatar Jul 13 '16 13:07 jace