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
This commit is contained in:
parent
764352afc7
commit
f2075750ed
2 changed files with 46 additions and 2 deletions
|
|
@ -0,0 +1,33 @@
|
|||
"""add "is_retroactive" to Thread and fix nullable columns
|
||||
|
||||
Revision ID: 6af2d8f6be76
|
||||
Revises: 29f85e56b6d4
|
||||
Create Date: 2025-05-02 11:21:54.023587
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.sql import false
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '6af2d8f6be76'
|
||||
down_revision = '29f85e56b6d4'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
with op.batch_alter_table('thread', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('is_retroactive', sa.Boolean(), server_default=false(), nullable=False, comment="Indicates if thread ID was added after the original message was sent (e.g. to link a parent message which didn't have a thread ID to a thread)."))
|
||||
batch_op.alter_column('thread_id',
|
||||
existing_type=sa.TEXT(),
|
||||
nullable=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
with op.batch_alter_table('thread', schema=None) as batch_op:
|
||||
batch_op.alter_column('thread_id',
|
||||
existing_type=sa.TEXT(),
|
||||
nullable=True)
|
||||
batch_op.drop_column('is_retroactive')
|
||||
|
|
@ -40,6 +40,7 @@ from sqlalchemy import (
|
|||
event,
|
||||
)
|
||||
from sqlalchemy.orm import declarative_base, relationship
|
||||
from sqlalchemy.sql import false
|
||||
from sqlalchemy.sql.functions import now
|
||||
from sqlalchemy.types import TypeDecorator
|
||||
from twisted.words.protocols.jabber import jid
|
||||
|
|
@ -433,8 +434,18 @@ class Thread(Base):
|
|||
primary_key=True,
|
||||
)
|
||||
history_uid = Column(ForeignKey("history.uid", ondelete="CASCADE"))
|
||||
thread_id = Column(Text)
|
||||
parent_id = Column(Text)
|
||||
thread_id = Column(Text, nullable=False)
|
||||
parent_id = Column(Text, nullable=True)
|
||||
is_retroactive = Column(
|
||||
Boolean,
|
||||
default=False,
|
||||
nullable=False,
|
||||
server_default=false(),
|
||||
comment=(
|
||||
"Indicates if thread ID was added after the original message was sent (e.g. "
|
||||
"to link a parent message which didn't have a thread ID to a thread)."
|
||||
)
|
||||
)
|
||||
|
||||
history = relationship("History", uselist=False, back_populates="thread")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue