"""Posts parent table and PostTopic table for the data_science_dev database.""" from __future__ import annotations from pipelines.orm.data_science_dev.base import ( DataScienceDevBase, DataScienceDevTableBase, ) from pipelines.orm.data_science_dev.posts.columns import PostsColumns from sqlalchemy import BigInteger, Index, SmallInteger from sqlalchemy.orm import Mapped, mapped_column class Posts(PostsColumns, DataScienceDevBase): """Parent partitioned table for posts, partitioned by week on `date`.""" __tablename__ = "posts" __table_args__ = ({"postgresql_partition_by": "RANGE (date)"},) class PostTopic(DataScienceDevTableBase): """Stores BERTopic topic assignments for posts. post_id references main.posts but without a FK constraint since posts is a partitioned table. """ __tablename__ = "post_topic" __table_args__ = (Index("ix_post_topic_post_id", "post_id"),) post_id: Mapped[int] = mapped_column(BigInteger) topic_id: Mapped[int] = mapped_column(SmallInteger) topic_label: Mapped[str | None] model_version: Mapped[str | None]