From 8fa850534cc9220d671f5523c0788c2a5dc02c88 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 25 Mar 2026 09:59:20 -0400 Subject: [PATCH] =?UTF-8?q?feat(briefing):=20add=20migration=200028=20?= =?UTF-8?q?=E2=80=94=20briefing=20improvements=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also comments out nvidia GPU reservation in docker-compose.yml (no nvidia-container-toolkit on this host). Co-Authored-By: Claude Sonnet 4.6 --- .../0028_add_briefing_improvements.py | 55 +++++++++++++++++++ docker-compose.yml | 15 ++--- 2 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 alembic/versions/0028_add_briefing_improvements.py diff --git a/alembic/versions/0028_add_briefing_improvements.py b/alembic/versions/0028_add_briefing_improvements.py new file mode 100644 index 0000000..d7d35b8 --- /dev/null +++ b/alembic/versions/0028_add_briefing_improvements.py @@ -0,0 +1,55 @@ +"""Add briefing improvements: rss_items topics/classified_at, messages metadata, + rss_item_reactions, briefing_task_snapshot.""" + +from alembic import op + +revision = "0028" +down_revision = "0027" + + +def upgrade() -> None: + op.execute(""" + ALTER TABLE rss_items + ADD COLUMN IF NOT EXISTS topics TEXT[] DEFAULT '{}', + ADD COLUMN IF NOT EXISTS classified_at TIMESTAMPTZ + """) + op.execute(""" + ALTER TABLE messages + ADD COLUMN IF NOT EXISTS metadata JSONB + """) + op.execute(""" + CREATE TABLE IF NOT EXISTS rss_item_reactions ( + id SERIAL PRIMARY KEY, + user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, + rss_item_id INTEGER NOT NULL REFERENCES rss_items(id) ON DELETE CASCADE, + reaction TEXT NOT NULL CHECK (reaction IN ('up', 'down')), + created_at TIMESTAMPTZ DEFAULT NOW(), + UNIQUE (user_id, rss_item_id) + ) + """) + op.execute( + "CREATE INDEX IF NOT EXISTS ix_rss_item_reactions_user_id " + "ON rss_item_reactions(user_id)" + ) + op.execute(""" + CREATE TABLE IF NOT EXISTS briefing_task_snapshot ( + id SERIAL PRIMARY KEY, + user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, + task_id INTEGER NOT NULL REFERENCES notes(id) ON DELETE CASCADE, + snapshot_hash TEXT NOT NULL, + last_briefed TIMESTAMPTZ DEFAULT NOW(), + UNIQUE (user_id, task_id) + ) + """) + op.execute( + "CREATE INDEX IF NOT EXISTS ix_briefing_task_snapshot_user_id " + "ON briefing_task_snapshot(user_id)" + ) + + +def downgrade() -> None: + op.execute("DROP TABLE IF EXISTS briefing_task_snapshot") + op.execute("DROP TABLE IF EXISTS rss_item_reactions") + op.execute("ALTER TABLE messages DROP COLUMN IF EXISTS metadata") + op.execute("ALTER TABLE rss_items DROP COLUMN IF EXISTS classified_at") + op.execute("ALTER TABLE rss_items DROP COLUMN IF EXISTS topics") diff --git a/docker-compose.yml b/docker-compose.yml index 1879389..5cf9bb6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -55,13 +55,14 @@ services: OLLAMA_NUM_PARALLEL: "2" OLLAMA_KEEP_ALIVE: "30m" OLLAMA_FLASH_ATTENTION: "1" - deploy: - resources: - reservations: - devices: - - driver: nvidia - count: all - capabilities: [gpu] + # GPU reservation commented out — no nvidia-container-toolkit on this host + # deploy: + # resources: + # reservations: + # devices: + # - driver: nvidia + # count: all + # capabilities: [gpu] volumes: pgdata: