feat(bot): support concurrent drafts and reply-based edits with error resilience
This commit is contained in:
@@ -445,6 +445,7 @@ async def ensure_bot_drafts_table(engine: AsyncEngine) -> None:
|
||||
missing JSONB,
|
||||
status VARCHAR(16) NOT NULL DEFAULT 'active',
|
||||
source VARCHAR(16),
|
||||
source_message_id BIGINT,
|
||||
review_message_id BIGINT,
|
||||
last_bale_update_at TIMESTAMPTZ,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
@@ -455,6 +456,9 @@ async def ensure_bot_drafts_table(engine: AsyncEngine) -> None:
|
||||
"CREATE INDEX IF NOT EXISTS ix_bot_drafts_chat_id ON bot_drafts(chat_id)",
|
||||
"CREATE INDEX IF NOT EXISTS ix_bot_drafts_chat_status ON bot_drafts(chat_id, status)",
|
||||
"ALTER TABLE bot_drafts ADD COLUMN IF NOT EXISTS last_bale_update_at TIMESTAMPTZ",
|
||||
"ALTER TABLE bot_drafts ADD COLUMN IF NOT EXISTS source_message_id BIGINT",
|
||||
"CREATE INDEX IF NOT EXISTS ix_bot_drafts_review_msg ON bot_drafts(review_message_id)",
|
||||
"CREATE INDEX IF NOT EXISTS ix_bot_drafts_source_msg ON bot_drafts(source_message_id)",
|
||||
)
|
||||
async with engine.begin() as conn:
|
||||
await conn.execute(text(ddl))
|
||||
|
||||
@@ -14,6 +14,7 @@ class BotDraft(Base):
|
||||
missing = Column(JSONB)
|
||||
status = Column(String(16), nullable=False, default="active")
|
||||
source = Column(String(16))
|
||||
source_message_id = Column(BigInteger)
|
||||
review_message_id = Column(BigInteger)
|
||||
last_bale_update_at = Column(DateTime(timezone=True))
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
Reference in New Issue
Block a user