Fix the onboarding data migration on Postgres #136
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/onboarding-migration-postgres"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The onboarding data migration (
c1f0a7d92b41, merged with the coach-marks PR) compares and assigns thejsoncolumnhints_seenwith raw SQL strings. SQLite treats json as text and accepts it; Postgres has no=operator for thejsontype and does not implicitly cast avarcharbind parameter on assignment, soalembic upgrade headfails while planning the statement.Because
sync_runner._ensure_schema()runsupgrade headin the FastAPI lifespan, a deploy from current main would fail to boot the pod on Postgres (ZAD).Found by the new migration-test harness on the
fase-1-fundament-v2branch (PR #123): itsbackend-test-postgresjob went red on exactly this. That is the class of bug the harness was built to catch - the revision passes on SQLite and fails on Postgres.Fix
Rewritten with typed SQLAlchemy constructs: a
sa.tablewith asa.JSONcolumn (so the bind parameter is serialized and typed correctly on both dialects) and an explicitCAST(hints_seen AS TEXT)for the comparisons. Semantics unchanged: only rows with an empty/NULLhints_seenbelonging to users with a connected account are marked, and re-running stays a no-op.Verified
upgrade head->downgrade base->upgrade headagainst Postgres 17: clean.After merge, PR #123 needs one more rebase to pick this up; its own migration re-parents onto this chain.