Skip to content

fix: restore deleted j0k1 migration to keep released chain resolvable - #17

Merged
Devathmaj merged 1 commit into
mainfrom
llm-reddit-db-update
Aug 14, 2026
Merged

fix: restore deleted j0k1 migration to keep released chain resolvable#17
Devathmaj merged 1 commit into
mainfrom
llm-reddit-db-update

Conversation

@Devathmaj

Copy link
Copy Markdown
Owner

Description

Fixes a startup crash on existing databases. PR #15 deleted a released Alembic migration, j0k1l2m3n4o5 (schema_freeze_vendor_mappings), and rewired the chain to skip it. Any database that was stamped at that revision (it was the chain head between 2026-07-23 and 2026-08-13) can no longer resolve its current revision, so alembic upgrade head fails at app startup with:

alembic.util.exc.CommandError: Can't locate revision identified by 'j0k1l2m3n4o5'

Alembic migrations must never be deleted once released — the scripts directory and the DB's alembic_version table must always agree.

Changes:

  1. Restored j0k1l2m3n4o5_schema_freeze_vendor_mappings.py with its original content. Its upgrade() is a safe no-op on fresh databases (h4d5e6f7a8b9 already creates vendor_mappings) and skips when the table exists, so re-adding it has no effect on new installs. Added a docstring NOTE that this released revision must never be deleted.
  2. Rewired k2l3m4n5o6p7_add_notification_outbox.py back to down_revision = j0k1l2m3n4o5, restoring the original single linear chain with one head (m6n7o8p9q0r1). Also made its notification_outbox creation defensive (skips when the table already exists) so create_all-built databases upgrade cleanly.

The affected databases need no manual fix — re-running the app's startup migration now resolves from j0k1l2m3n4o5 to head automatically.

Type of Change

  • Bug fix
  • New feature
  • New source
  • Configuration / settings change
  • Database migration
  • Documentation update
  • Refactor (no functional change)
  • Other:

Affected Components

  • Scheduler / Dispatcher
  • HTTP Policy Layer (http_policy.py)
  • RSS Collector
  • Website Collector
  • Reddit Integration
  • AI Layer (Groq / Gemini)
  • Email Notifications
  • Database / Migrations
  • API / Routers
  • Configuration / Settings

Testing

  • Ran pytest — all tests pass (359 passed, 15 skipped)
  • Ran ruff check . && ruff format . — no lint errors
  • Ran python scripts/verify_sources.py — all sources resolve (if sources were added or modified)
  • Added unit tests for new business logic
  • Added integration tests using fixtures or recorded responses (no live network calls)
  • Mocked Reddit API client in all new tests
  • Mocked Groq / Gemini responses in all new tests

Migration

  • This PR includes an Alembic migration change
  • The migration is safe to apply to a live database without downtime
  • A sensible server-side default is provided for any new columns

Notes:
No new schema change — this restores a previously released revision so alembic upgrade head resolves on existing databases. The restored j0k1l2m3n4o5.upgrade() is a no-op (table already created by an earlier migration). The k2l3m4n5o6p7 outbox creation is now defensive against pre-existing tables from create_all-built databases.

Policy Checklist

  • This PR touches one or more policy-sensitive files

AI Layer Changes

N/A — no prompt, schema, or provider logic changed.

Additional Notes

Verification: alembic history and alembic heads show a single linear chain with one head (m6n7o8p9q0r1); tests/test_migrations.py enforces the single-head/linear invariant and passes; full suite is green.

@Devathmaj
Devathmaj merged commit 1ed10a4 into main Aug 14, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant