feat: add thread_id column to Podcast model

This commit is contained in:
CREDO23 2026-01-26 15:56:15 +02:00
parent 272e675669
commit 062998738a
2 changed files with 48 additions and 0 deletions

View file

@ -0,0 +1,40 @@
"""Add thread_id to podcasts
Revision ID: 80
Revises: 79
Create Date: 2026-01-23
"""
from collections.abc import Sequence
from alembic import op
revision: str = "80"
down_revision: str | None = "79"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
"""Add thread_id column to podcasts."""
op.execute(
"""
ALTER TABLE podcasts
ADD COLUMN IF NOT EXISTS thread_id INTEGER
REFERENCES new_chat_threads(id) ON DELETE SET NULL;
"""
)
op.execute(
"""
CREATE INDEX IF NOT EXISTS ix_podcasts_thread_id
ON podcasts(thread_id);
"""
)
def downgrade() -> None:
"""Remove thread_id column from podcasts."""
op.execute("DROP INDEX IF EXISTS ix_podcasts_thread_id")
op.execute("ALTER TABLE podcasts DROP COLUMN IF EXISTS thread_id")

View file

@ -693,6 +693,14 @@ class Podcast(BaseModel, TimestampMixin):
)
search_space = relationship("SearchSpace", back_populates="podcasts")
thread_id = Column(
Integer,
ForeignKey("new_chat_threads.id", ondelete="SET NULL"),
nullable=True,
index=True,
)
thread = relationship("NewChatThread")
class SearchSpace(BaseModel, TimestampMixin):
__tablename__ = "searchspaces"