Repository navigation
Upgrade pre-migration v1 databases in place instead of failing deploy - #3
Merged
Merged
Conversation
The first deploy with Alembic failed with 'relation "users" already exists': production was created by v1's create_all(), so it had tables but no alembic_version, and the v2 migration tried to create everything. The v2 migration now detects that case and upgrades the v1 tables in place, keeping all data: - adds the new columns, recall tables and ON DELETE rules, each only if missing - backfills canonical_url; later duplicates of a link are kept but suffixed so the new per-user unique constraint holds - recomputes read time from word count (YouTube keeps v1's value) - removes v1 "opened" and "skipped" events, which v2 treats as noise, and collapses duplicate clicks so (item_id, event_type) can be unique Fresh databases and databases already at this revision are unaffected, and both paths produce an identical schema (pg_dump diff, alembic check). New tests run both paths against real throwaway databases, using the exact v1 DDL; the v1 test fails on the old migration with the production error. Also: a failed profile-embedding call no longer aborts the dispatch build. Migrated users have profile text but no embedding, so their first v2 dispatch computes one; on failure it now ranks without it and retries later.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first deploy with Alembic failed with 'relation "users" already exists': production was created by v1's create_all(), so it had tables but no alembic_version, and the v2 migration tried to create everything.
The v2 migration now detects that case and upgrades the v1 tables in place, keeping all data:
Fresh databases and databases already at this revision are unaffected, and both paths produce an identical schema (pg_dump diff, alembic check). New tests run both paths against real throwaway databases, using the exact v1 DDL; the v1 test fails on the old migration with the production error.
Also: a failed profile-embedding call no longer aborts the dispatch build. Migrated users have profile text but no embedding, so their first v2 dispatch computes one; on failure it now ranks without it and retries later.