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
30 lines
915 B
Python
30 lines
915 B
Python
"""fix news_articles url uniqueness to per-bill scope
|
|
|
|
Previously url was globally unique, meaning the same article could only
|
|
be stored for one bill. This changes it to (bill_id, url) unique so the
|
|
same article can appear in multiple bills' news panels.
|
|
|
|
Revision ID: 0009
|
|
Revises: 0008
|
|
Create Date: 2026-03-01
|
|
"""
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision = "0009"
|
|
down_revision = "0008"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# Drop the old global unique constraint on url
|
|
op.drop_constraint("news_articles_url_key", "news_articles", type_="unique")
|
|
# Add per-bill unique constraint
|
|
op.create_unique_constraint("uq_news_articles_bill_url", "news_articles", ["bill_id", "url"])
|
|
|
|
|
|
def downgrade():
|
|
op.drop_constraint("uq_news_articles_bill_url", "news_articles", type_="unique")
|
|
op.create_unique_constraint("news_articles_url_key", "news_articles", ["url"])
|