From b03ae32a9ed62faa59b9a043f86d94ca038a8f58 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Thu, 24 Jun 2021 18:39:23 +0200 Subject: [PATCH] Add EditSession table --- matcher/model.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/matcher/model.py b/matcher/model.py index ef71cc7..1333267 100644 --- a/matcher/model.py +++ b/matcher/model.py @@ -300,6 +300,17 @@ class User(Base, UserMixin): def is_active(self): return self.active +class EditSession(Base): + __tablename__ = 'edit_session' + id = Column(Integer, primary_key=True) + user_id = Column(Integer, ForeignKey(User.id)) + created = Column(DateTime, default=now_utc(), nullable=False) + edit_list = Column(postgresql.JSONB) + comment = Column(String) + + user = relationship('User') + changeset = relationship('Changeset', back_populates='edit_session', uselist=False) + class Changeset(Base): __tablename__ = 'changeset' @@ -308,12 +319,15 @@ class Changeset(Base): comment = Column(String) user_id = Column(Integer, ForeignKey(User.id)) update_count = Column(Integer, nullable=False) + edit_session_id = Column(Integer, ForeignKey(EditSession.id)) user = relationship('User', backref=backref('changesets', lazy='dynamic', order_by='Changeset.created.desc()')) + edit_session = relationship('EditSession', back_populates='changeset') + class ChangesetEdit(Base): __tablename__ = 'changeset_edit'