Mercurial > libervia-backend
comparison libervia/backend/memory/sqla_mapping.py @ 4365:f6672bc80897
storage (mapping): Fix `nullable` for thread ID, and add a `is_retroactive` field:
`is_retroactive` is used to link a thread in a parent message when it didn't have the
thread initially.
rel 457
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 06 May 2025 00:21:24 +0200 |
parents | 0d7bb4df2343 |
children |
comparison
equal
deleted
inserted
replaced
4364:fa300abc3cb6 | 4365:f6672bc80897 |
---|---|
38 Text, | 38 Text, |
39 UniqueConstraint, | 39 UniqueConstraint, |
40 event, | 40 event, |
41 ) | 41 ) |
42 from sqlalchemy.orm import declarative_base, relationship | 42 from sqlalchemy.orm import declarative_base, relationship |
43 from sqlalchemy.sql import false | |
43 from sqlalchemy.sql.functions import now | 44 from sqlalchemy.sql.functions import now |
44 from sqlalchemy.types import TypeDecorator | 45 from sqlalchemy.types import TypeDecorator |
45 from twisted.words.protocols.jabber import jid | 46 from twisted.words.protocols.jabber import jid |
46 from wokkel import generic | 47 from wokkel import generic |
47 | 48 |
431 id = Column( | 432 id = Column( |
432 Integer, | 433 Integer, |
433 primary_key=True, | 434 primary_key=True, |
434 ) | 435 ) |
435 history_uid = Column(ForeignKey("history.uid", ondelete="CASCADE")) | 436 history_uid = Column(ForeignKey("history.uid", ondelete="CASCADE")) |
436 thread_id = Column(Text) | 437 thread_id = Column(Text, nullable=False) |
437 parent_id = Column(Text) | 438 parent_id = Column(Text, nullable=True) |
439 is_retroactive = Column( | |
440 Boolean, | |
441 default=False, | |
442 nullable=False, | |
443 server_default=false(), | |
444 comment=( | |
445 "Indicates if thread ID was added after the original message was sent (e.g. " | |
446 "to link a parent message which didn't have a thread ID to a thread)." | |
447 ) | |
448 ) | |
438 | 449 |
439 history = relationship("History", uselist=False, back_populates="thread") | 450 history = relationship("History", uselist=False, back_populates="thread") |
440 | 451 |
441 def __repr__(self): | 452 def __repr__(self): |
442 return f"Thread<{self.thread_id} [parent: {self.parent_id}]>" | 453 return f"Thread<{self.thread_id} [parent: {self.parent_id}]>" |