Repository navigation
Use built-in pagination instead of paginator - #72
Closed
ianmacartney wants to merge 1 commit into
Closed
ianmacartney wants to merge 1 commit into
ianmacartney wants to merge 1 commit into
Conversation
Migrations now paginate with ctx.db.query(table).paginate() by default, which components can call once per transaction. The convex-helpers paginator is only used to resume in-progress migrations whose stored cursor came from the paginator (versions 0.3.5-0.3.7). The schema option is no longer required for customRange, except to resume such a legacy cursor with a custom range. Adds isPaginatorCursor (isNewFormatCursor is kept, deprecated), installs convex-test from pkg.pr.new for the one-paginate-per-transaction check, and runs runToCompletion in tests from an action context.
commit: |
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.
Migrations now page through tables with built-in
ctx.db.query(table).paginate()by default, in place of thepaginatorfromconvex-helpers/server/pagination.This depends on the upcoming Convex release, which lets components call
.paginate()once per transaction. It temporarily installs convex-test from https://pkg.pr.new/convex-test@163 (devDependency), which enforces that limit, until a real release.Changes
src/client/index.ts: each migration batch usesctx.db.query(table)(pluscustomRange) and.paginate(). Thepaginatoris kept only as a fallback for legacy cursors: if the stored cursor came from the paginator (versions 0.3.5-0.3.7), that batch and later ones resume with the paginator, so in-progress migrations keep going. Adds an exportedisPaginatorCursor(cursor). It is true when the cursor is a JSON array ending in a numeric_creationTimeand a string_id, so it does not match convex-test's built-in cursors, which are JSON arrays of strings.isNewFormatCursoris still exported, marked deprecated, and behaves as before.schemaoption: no longer required forcustomRange. It still gives type safety. At runtime it is only needed to resume a legacy paginator cursor on a migration that has acustomRange. Without it, that case throws an error saying to pass the schema or restart from anullcursor.schemaJSDoc, and theexample/convex/localComponent/example.tscomment are updated to match.isPaginatorCursorunit tests, plus a test that resumes a migration from a paginator cursor. TherunToCompletiontests now run int.actionrather thant.run, sincerunToCompletionneeds an action context and loops overrunMutation. Undert.runall batches share one transaction, which the new convex-test rejects.convex-helpersstays as a peer dependency because the legacy fallback still uses it.One paginate per transaction
Each migration batch calls
.paginate()once. Whenmigrations.runOne,runSerially, or a migration function is called from a mutation, the first batch runs inside the caller's transaction. So a mutation that already paginated, or that starts two migrations, will now fail on that call.migrateOnecallbacks that call.paginate()themselves will also fail. Later batches run in their own scheduled transactions.runToCompletionruns each batch in its own transaction when called from an action.