Skip to content

fix(db): give the session revoke migration its own version - #189

Open
JOY (JOY) wants to merge 2 commits into
mainfrom
fix/duplicate-migration-version
Open

JOY (JOY) wants to merge 2 commits into
mainfrom
fix/duplicate-migration-version

Conversation

@JOY

@JOY JOY (JOY) commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

main is broken for every fresh install. #182 (20261016200000_crove_kernel_inbound_drop_count.sql) and #186 (20261016200000_crove_kernel_session_revoke_rank_revoked.sql) share a version. The runner keys crove_meta.schema_migrations by version, so applying migrations stops at the second file:

migration 20261016200000_crove_kernel_session_revoke_rank_revoked.sql failed:
duplicate key value violates unique constraint "schema_migrations_pkey"

This breaks docker compose up (the migrate service exits 1), the CI db job and the invariant suite on main at 10b21d7. I reproduced it locally with vitest run --project db.

Fix

Tests

Local, on main at 10b21d7 plus this change, PostgreSQL 17:

  • pnpm lint, pnpm typecheck and pnpm docs:check pass.
  • Unit tests: 309 passed, 6 skipped. Database tests: 300 passed, 5 skipped. Both failed before this change.
  • Invariant suite: 261/261.

Touches supabase/migrations/ (a protected path), so the invariant job from the base runs. Because the base itself cannot migrate, that job may fail until this merges. It is not the PR's own failure.

🤖 Generated with Claude Code

https://claude.ai/code/session_013LrvuThKGaPX1uDwUiwmGQ


Generated by Claude Code

Summary by CodeRabbit

  • Tests
    • Added automated checks to catch missing or incorrectly formatted database migration versions, as well as duplicate versions that could disrupt fresh installations. The checks also help ensure new migrations use versions later than those already on the main branch. These safeguards help identify migration issues before release.

#182 and #186 both added a migration at 20261016200000. The runner keys
crove_meta.schema_migrations by version, so every fresh install (compose,
the CI db job, the invariant suite) stops at the second file with
"duplicate key value violates unique constraint schema_migrations_pkey".

#186's file sorts second, so no database can have applied it under
20261016200000; it moves to 20261016200100 unchanged. A unit test now
fails CI when two migration files share a version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013LrvuThKGaPX1uDwUiwmGQ

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@vercel

vercel Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
crove Ready Ready Preview Oct 15, 2026 8:11pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 31 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 097755d7-4f42-43a8-bd4e-4d5526de7958
📥 Commits

Reviewing files that changed from the base of the PR and between 6028295 and b9738f6.

📒 Files selected for processing: 1
  • tools/test/migration-versions.test.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 117ddb9a-08e2-4397-b4fe-3cc94b182d35
📥 Commits

Reviewing files that changed from the base of the PR and between 10b21d7 and 6028295.

📒 Files selected for processing: 2
  • supabase/migrations/20261016200100_crove_kernel_session_revoke_rank_revoked.sql
  • tools/test/migration-versions.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

Adds a Vitest test that checks SQL migration filenames for a 14-digit version prefix and unique versions. The test also requires the migration directory to contain at least one file.

Changes: Migration version validation

Layer / File(s) Summary
Validate migration filenames
tools/test/migration-versions.test.ts
The test checks that the migration directory is nonempty, each SQL filename starts with a 14-digit version, and no version is shared. Comments describe duplicate-version behavior and timestamp requirements.

Priority: ⬆️ High

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 60282

The migration version collision that blocked fresh installs is corrected, and CI runs a test to catch duplicate migration versions. No actionable merge risk remains in the reviewed changes.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: assigning the session revoke migration a unique version.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new test suite in tools/test/migration-versions.test.ts to verify that all Supabase migration files have unique 14-digit version prefixes. Feedback suggests enhancing this test to validate the entire filename against the strict naming convention pattern used by the migration runner, which would prevent runtime migration failures and allow for cleaner, safer TypeScript code.

Comment thread tools/test/migration-versions.test.ts Outdated
… rule

A misnamed file now fails the unit test without a database, before the runner
rejects it at migrate time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013LrvuThKGaPX1uDwUiwmGQ

This branch was successfully deployed

1 active deployment
Preview — b9738f6f Deployed Oct 15, 2026 by vercel[bot]
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.

2 participants