Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
name: Run tests
name: Test and lint
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
push:
branches: ["main"]
branches: [main]
pull_request:
branches: ["main"]
branches: ["**"]

jobs:
build:
check:
name: Test and lint
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

- name: Node setup
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: "18.x"
cache-dependency-path: package.json
node-version: "20.x"
cache: "npm"
- run: npm i
- run: npm ci
- run: cd example && npm i && cd ..
- run: npm test

- name: Install and build
run: |
npm i
npm run build
- name: Publish package for testing branch
run: npx pkg-pr-new publish
- name: Test
run: |
npm run test
npm run typecheck
npm run lint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ node_modules
frontend/package.json
# npm pack output
*.tgz
*.tsbuildinfo
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,11 @@ await migrations.runOne(ctx, internal.example.setDefaultValue);

- If it is already running it will refuse to start another duplicate worker.
- If it had previously failed on some batch, it will continue from that batch
unless you manually specify `cursor`.
unless you manually specify `cursor` or `reset`.
- If you provide an explicit `cursor` (`null` means to start at the beginning),
it will start from there.
- If you pass `reset: true`, it will restart the migration from the beginning
for all migrations in the group (including any `next` migrations).
- If you pass `true` for `dryRun` then it will run one batch and then throw,
so no changes are committed, and you can see what it would have done.
See [below](#test-a-migration-with-dryrun)
Expand Down Expand Up @@ -277,7 +279,15 @@ npx convex run migrations:runIt '{dryRun: true}'

### Restart a migration

Pass `null` for the `cursor` to force a migration to start over.
Pass `reset: true` to force a migration to start over from the beginning.
This will reset the cursor for all migrations in the group.

```sh
npx convex run migrations:runIt '{reset: true}'
```

Alternatively, you can pass `null` for the `cursor` to restart just the
current migration:

```sh
npx convex run migrations:runIt '{cursor: null}'
Expand Down
8 changes: 0 additions & 8 deletions commonjs.json

This file was deleted.

3 changes: 3 additions & 0 deletions convex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"functions": "example/convex"
}
3 changes: 2 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default [
ignores: [
"dist/**",
"eslint.config.js",
"vitest.config.ts",
"**/_generated/",
"node10stubs.mjs",
],
Expand All @@ -19,7 +20,7 @@ export default [

parserOptions: {
project: true,
tsconfigRootDir: ".",
tsconfigRootDir: import.meta.dirname,
},
},
},
Expand Down
8 changes: 0 additions & 8 deletions esm.json

This file was deleted.

1 change: 1 addition & 0 deletions example/convex/_generated/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export declare const components: {
fnHandle: string;
name: string;
next?: Array<{ fnHandle: string; name: string }>;
reset?: boolean;
},
{
batchSize?: number;
Expand Down
4 changes: 2 additions & 2 deletions example/convex/example.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Migrations, MigrationStatus } from "@convex-dev/migrations";
import { Migrations, type MigrationStatus } from "@convex-dev/migrations";
import { v } from "convex/values";
import { components, internal } from "./_generated/api.js";
import { DataModel } from "./_generated/dataModel.js";
import type { DataModel } from "./_generated/dataModel.js";
import { internalMutation, internalQuery } from "./_generated/server.js";

export const migrations = new Migrations<DataModel>(components.migrations);
Expand Down
Loading
Loading