Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Included participant_id in email writes
Browse files Browse the repository at this point in the history
  • Loading branch information
aandis committed Jan 17, 2016
1 parent a30be4a commit 7210b23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions gratipay/models/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,9 @@ def add_email(self, email, resend_threshold='3 minutes'):
add_event(c, 'participant', dict(id=self.id, action='add', values=dict(email=email)))
c.run("""
INSERT INTO emails
(address, nonce, verification_start, participant)
VALUES (%s, %s, %s, %s)
""", (email, nonce, verification_start, self.username))
(address, nonce, verification_start, participant, participant_id)
VALUES (%s, %s, %s, %s, %s)
""", (email, nonce, verification_start, self.username, self.id))
except IntegrityError:
nonce = self.db.one("""
UPDATE emails
Expand Down
4 changes: 3 additions & 1 deletion sql/branch.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
ALTER TABLE emails ADD COLUMN participant_id bigint DEFAULT NULL
REFERENCES participants(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
REFERENCES participants(id) ON UPDATE RESTRICT ON DELETE RESTRICT;

ALTER TABLE emails ADD UNIQUE (participant_id, address);

0 comments on commit 7210b23

Please sign in to comment.