mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-05 23:42:21 +00:00
feat: add thread_id column to Podcast model
This commit is contained in:
parent
272e675669
commit
062998738a
2 changed files with 48 additions and 0 deletions
|
|
@ -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")
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue