From b3fca3ced4db16b6f22ba5852dd567cfea5005d7 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 27 May 2026 18:16:18 -0400 Subject: [PATCH] migration: drop chat/journal/push/curator/weather tables (Phase 9) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 8 deleted the Python models for these tables; this migration drops the orphan SQL. Dropped tables (CASCADE-safe): conversations, messages, generation_tool_log, moments + moment_embeddings + moment_people/places/tasks/notes, pending_curator_actions, push_subscriptions, weather_cache, rss_item_embeddings (legacy pre-pivot experiment) Dropped per-user settings: every voice_*, journal_*, briefing_*, curator_* key, plus default_model, background_model, assistant_name, auto_consolidate_tasks, chat_retention_days, think_enabled, rag_default_scope. Hard cutover — no downgrade. Existing data in these tables is lost; the spec explicitly accepted this in exchange for a clean schema. Co-Authored-By: Claude Opus 4.7 (1M context) --- ...3_drop_chat_journal_push_curator_tables.py | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 alembic/versions/0053_drop_chat_journal_push_curator_tables.py diff --git a/alembic/versions/0053_drop_chat_journal_push_curator_tables.py b/alembic/versions/0053_drop_chat_journal_push_curator_tables.py new file mode 100644 index 0000000..e21823a --- /dev/null +++ b/alembic/versions/0053_drop_chat_journal_push_curator_tables.py @@ -0,0 +1,82 @@ +"""drop chat / journal / push / curator / weather tables + +Revision ID: 0053 +Revises: 0052 +Create Date: 2026-05-27 + +Phase 9 of the MCP-first pivot. The Python models for these tables were +deleted in Phase 8 (commit 91bafb6); this migration drops the orphan +SQL tables and cleans up dead per-user setting rows. + +Hard-cutover: existing rows in these tables are discarded. The +accompanying spec at docs/superpowers/specs/2026-05-26-mcp-first-pivot-design.md +explicitly accepted this loss. +""" +from alembic import op + + +revision = "0053" +down_revision = "0052" +branch_labels = None +depends_on = None + + +# Order: junction tables first so the parent tables don't trip FK drops +# even with CASCADE — keeps the migration readable. +_DEAD_TABLES = [ + # Moments + junction tables (journal entity links) + "moment_notes", + "moment_tasks", + "moment_places", + "moment_people", + "moment_embeddings", + "moments", + # Chat / generation telemetry + "generation_tool_log", + "messages", + "conversations", + # Curator approval queue + "pending_curator_actions", + # Push notifications + "push_subscriptions", + # Weather cache (journal-prep background fetcher) + "weather_cache", + # Legacy RSS-item embeddings (pre-MCP pivot, briefly experimented with) + "rss_item_embeddings", +] + + +# Specific setting keys to drop. Anything matching the LIKE patterns in +# upgrade() is also nuked; the explicit list catches one-off keys that +# don't fit the namespaced patterns. +_DEAD_SETTING_KEYS = [ + "default_model", + "background_model", + "assistant_name", + "auto_consolidate_tasks", + "chat_retention_days", + "think_enabled", + "rag_default_scope", +] + + +def upgrade() -> None: + for table in _DEAD_TABLES: + op.execute(f"DROP TABLE IF EXISTS {table} CASCADE") + + keys_csv = ",".join(f"'{k}'" for k in _DEAD_SETTING_KEYS) + op.execute( + "DELETE FROM settings WHERE " + "key LIKE 'voice_%' OR " + "key LIKE 'journal_%' OR " + "key LIKE 'briefing_%' OR " + "key LIKE 'curator_%' OR " + f"key IN ({keys_csv})" + ) + + +def downgrade() -> None: + raise NotImplementedError( + "No downgrade — hard cutover per the MCP-first pivot spec. " + "Rolling back is not supported at the database layer." + )