~sirn/fanboi2

ref: 98796226802a26b82c888365ad5b9cd331006792 fanboi2/fanboi2/models/topic_meta.py -rw-r--r-- 1.0 KiB
98796226Kridsada Thanabulpong Bump copyright year. 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from sqlalchemy.orm import relationship, backref
from sqlalchemy.sql.schema import Column, ForeignKey
from sqlalchemy.sql.sqltypes import Integer, DateTime
from ._base import Base


class TopicMeta(Base):
    """Model class that provides topic metadata. This model holds data that
    are related to internal workings of the topic model that are not part of
    the versionable records.
    """

    __tablename__ = 'topic_meta'

    topic_id = Column(Integer,
                      ForeignKey('topic.id'),
                      nullable=False,
                      primary_key=True,
                      autoincrement=False)

    post_count = Column(Integer, nullable=False)
    posted_at = Column(DateTime(timezone=True))
    bumped_at = Column(DateTime(timezone=True))

    topic = relationship('Topic',
                         backref=backref('meta',
                                         uselist=False,
                                         cascade='all,delete',
                                         lazy=True))