From 0fb0ff8c99fa84dc95143cb5f60c0f4cdd19619a Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Tue, 10 Jul 2018 10:02:54 +0200 Subject: [PATCH] Add an ID field to the Invite model It turned out the multi-field primary key is not a good idea. --- calsocial/models.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/calsocial/models.py b/calsocial/models.py index b4312fe..b61d502 100644 --- a/calsocial/models.py +++ b/calsocial/models.py @@ -597,19 +597,21 @@ class Invitation(db.Model): # pylint: disable=too-few-public-methods """ __tablename__ = 'invitations' + # pylint: disable=invalid-name + id = db.Column(db.Integer(), primary_key=True) #: The ID of the sender’s profile - sender_id = db.Column(db.Integer(), db.ForeignKey('profiles.id'), primary_key=True) + sender_id = db.Column(db.Integer(), db.ForeignKey('profiles.id'), index=True) sender = db.relationship('Profile', foreign_keys=[sender_id]) #: The ID of the invitee’s profile - invitee_id = db.Column(db.Integer(), db.ForeignKey('profiles.id'), primary_key=True) + invitee_id = db.Column(db.Integer(), db.ForeignKey('profiles.id'), index=True) invitee = db.relationship('Profile', foreign_keys=[invitee_id]) #: The ID of the event - event_id = db.Column(db.Integer(), db.ForeignKey('events.id'), primary_key=True) + event_id = db.Column(db.Integer(), db.ForeignKey('events.id'), index=True) event = db.relationship('Event', backref=db.backref('invitations', lazy='dynamic'))