Uh oh!
There was an error while loading. Please reload this page.
chore(db): re-runnable cosmetics migration + ordered migration runner (#196, #197) - #251
chore(db): re-runnable cosmetics migration + ordered migration runner (#196, #197)#251Jose-Gael-Cruz-Lopez wants to merge 14 commits into
Conversation
Warning Review limit reached
More reviews will be available in 56 minutes and 30 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying with |
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs | frontend | d225b53 | Jun 22 2026, 04:11 AM |
Previously --status ran the ledger CREATE TABLE IF NOT EXISTS inside the psycopg connection context, which commits on a clean exit and created the schema_migrations table as a side effect — contradicting the documented "no DB writes" contract. Check information_schema for the ledger instead and treat a missing table as zero applied migrations.
Without DATABASE_URL, --apply passed an empty connection string to
psycopg.connect(""), which silently falls back to libpq env defaults
(PGHOST, local socket) and yields a confusing connection error or an
unintended connection. Fail fast with a clear message instead.Deploying with |
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs | frontend-staging | dd97fac | Commit Preview URL Branch Preview URL | Jun 24 2026, 02:46 PM |
# Conflicts: # backend/db/migrate.py # backend/db/migrations/0009_cosmetics.sql
AndresL230
commented
Jun 25, 2026
Largely superseded. The ordered migration runner (#197) already landed as #252 (it's what the redesign uses), and the cosmetics re-runnability concern (#196) is mooted by the runner's applied-migration ledger (each file applies once). Closing — reopen if the cosmetics idempotency fix is still needed standalone. |
Two migration-hygiene fixes from the backend audit.
#196 —
migration_cosmetics.sqlis now idempotentThe five
ALTER TABLE user_settings ADD CONSTRAINT fk_…statements were bare; Postgres has noADD CONSTRAINT IF NOT EXISTS, so a second run aborted with "constraint already exists" (and, un-transactioned, left ambiguous partial state). Each is now wrapped in theDO $$ … IF NOT EXISTS (SELECT 1 FROM pg_constraint …)guard already used inmigration_gradebook.sql, so the migration is safely re-runnable.#197 — deterministic ordering + applied-migration ledger
Ordering lived only in prose headers, the root drift hazard behind the schema↔migration discrepancies elsewhere in the audit. This introduces:
schema_migrations(version, applied_at)ledger — newmigration_schema_migrations.sql+ mirrored intosupabase_schema.sql.db/migrate.py— an explicit orderedMANIFESTand a runner that applies each pending migration exactly once, in order, recording it.--statusinspects without writing;--applyruns pending ones (needs a directDATABASE_URL+psycopg, lazily imported — the PostgREST client can't run DDL).db/MIGRATIONS.md— documents the baseline/ledger/runner model and the "add a migration" checklist.supabase_schema.sqlremains the canonical baseline for fresh databases; the runner governs the incremental files going forward.Tests
test_migration_runner.py— manifest covers everymigration_*.sql(no orphan/phantom/dupe), the knowndrop-legacy → gradebookorder holds,pending()excludes applied + preserves order, and all five cosmetics FKs are guarded.Verification
ruff check .clean; gated suite green (+7 new);python -m db.migrate --statusruns with no DB.Closes#196, #197.