Self-hosted US Congress monitoring platform with AI policy briefs, bill/member/topic follows, ntfy + RSS + email notifications, alignment scoring, collections, and draft-letter generator. Authored by: Jack Levy
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Index, Integer, String, Text, UniqueConstraint
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class BillNote(Base):
|
|
__tablename__ = "bill_notes"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
user_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
|
|
bill_id = Column(String, ForeignKey("bills.bill_id", ondelete="CASCADE"), nullable=False)
|
|
content = Column(Text, nullable=False)
|
|
pinned = Column(Boolean, nullable=False, default=False)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
|
|
|
user = relationship("User", back_populates="bill_notes")
|
|
bill = relationship("Bill", back_populates="notes")
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint("user_id", "bill_id", name="uq_bill_notes_user_bill"),
|
|
Index("ix_bill_notes_user_id", "user_id"),
|
|
Index("ix_bill_notes_bill_id", "bill_id"),
|
|
)
|