feat: PocketVeto v1.0.0 — initial public release
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
This commit is contained in:
32
backend/alembic/versions/0012_dedupe_bill_actions_unique.py
Normal file
32
backend/alembic/versions/0012_dedupe_bill_actions_unique.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""Deduplicate bill_actions and add unique constraint on (bill_id, action_date, action_text)
|
||||
|
||||
Revision ID: 0012
|
||||
Revises: 0011
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
revision = "0012"
|
||||
down_revision = "0011"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# Remove duplicate rows keeping the lowest id for each (bill_id, action_date, action_text)
|
||||
op.execute("""
|
||||
DELETE FROM bill_actions a
|
||||
USING bill_actions b
|
||||
WHERE a.id > b.id
|
||||
AND a.bill_id = b.bill_id
|
||||
AND a.action_date IS NOT DISTINCT FROM b.action_date
|
||||
AND a.action_text IS NOT DISTINCT FROM b.action_text
|
||||
""")
|
||||
op.create_unique_constraint(
|
||||
"uq_bill_actions_bill_date_text",
|
||||
"bill_actions",
|
||||
["bill_id", "action_date", "action_text"],
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint("uq_bill_actions_bill_date_text", "bill_actions", type_="unique")
|
||||
Reference in New Issue
Block a user