Add an ID field to the Invite model

It turned out the multi-field primary key is not a good idea.
This commit is contained in:
Gergely Polonkai 2018-07-10 10:02:54 +02:00
parent 582e53038b
commit 0fb0ff8c99

View File

@ -597,19 +597,21 @@ class Invitation(db.Model): # pylint: disable=too-few-public-methods
""" """
__tablename__ = 'invitations' __tablename__ = 'invitations'
# pylint: disable=invalid-name
id = db.Column(db.Integer(), primary_key=True)
#: The ID of the senders profile #: The ID of the senders 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]) sender = db.relationship('Profile', foreign_keys=[sender_id])
#: The ID of the invitees profile #: The ID of the invitees 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]) invitee = db.relationship('Profile', foreign_keys=[invitee_id])
#: The ID of the event #: 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')) event = db.relationship('Event', backref=db.backref('invitations', lazy='dynamic'))