Spaces:
Sleeping
Sleeping
File size: 1,308 Bytes
266d7bc 804054e 266d7bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
import uuid
from uuid import UUID
from sqlalchemy import ARRAY, TIMESTAMP, BigInteger, String, Text, func
from sqlalchemy.dialects.postgresql import UUID as PG_UUID
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
from src.config import settings
class Base(DeclarativeBase):
pass
class FeedArticle(Base):
__tablename__ = settings.supabase_db.table_name
# Primary internal ID
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, index=True)
# External unique identifier
uuid: Mapped[UUID] = mapped_column(
PG_UUID(as_uuid=True),
default=uuid.uuid4,
unique=True,
nullable=False,
index=True,
)
# Article fields
feed_name: Mapped[str] = mapped_column(String, nullable=False)
feed_author: Mapped[str] = mapped_column(String, nullable=False)
article_authors: Mapped[list[str]] = mapped_column(ARRAY(String), nullable=False)
title: Mapped[str] = mapped_column(String, nullable=False)
url: Mapped[str] = mapped_column(String, unique=True, nullable=False)
content: Mapped[str] = mapped_column(Text, nullable=False)
published_at: Mapped[str] = mapped_column(TIMESTAMP, nullable=False)
created_at: Mapped[str] = mapped_column(TIMESTAMP, server_default=func.now(), nullable=False)
|