migration: drop chat/journal/push/curator/weather tables (Phase 9)

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) <noreply@anthropic.com>
This commit is contained in:
2026-05-27 18:16:18 -04:00
parent 8d73f553ca
commit b3fca3ced4
@@ -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."
)