Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/integration-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ jobs:
run: pnpm build
- name: Run Integration tests
run: pnpm test:integration
- name: Run init-journey matrix (nightly-only; excluded from PR runs)
run: pnpm --filter integration-tests test:init-journey
- name: Check working tree is clean
run: pnpm check:clean-tree
2 changes: 1 addition & 1 deletion docs/design/10-domains/migration/user-journeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ Three shapes the merge can take, all valid:

The graph is content-addressed: migration hashes change when ancestry changes, but the rules for "does this migration make sense from this contract?" are encoded in the verb taxonomy (`migration check`'s PN codes), not in branch ordering.

**Exercised by:** `converging-paths.e2e.test.ts`, `diamond-convergence.e2e.test.ts`, `divergence-and-refs.e2e.test.ts`.
**Exercised by:** `diamond-convergence.e2e.test.ts`, `divergence-and-refs.e2e.test.ts`.

---

Expand Down
1 change: 1 addition & 0 deletions test/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"pretest:vite-plugin": "pnpm -C ../.. --filter @repo/test-utils --filter @internal/vite-plugin-contract-emit... build",
"test": "vitest run",
"test:journeys": "vitest run --config vitest.journeys.config.ts",
"test:init-journey": "RUN_INIT_JOURNEY=1 vitest run --config vitest.journeys.config.ts test/cli-journeys/init-journey.e2e.test.ts",
"test:vite-plugin": "vitest run test/vite-plugin.hmr.e2e.test.ts",
"test:watch": "vitest",
"typecheck": "tsc --project tsconfig.json --noEmit",
Expand Down
6 changes: 4 additions & 2 deletions test/integration/test/cli-journeys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ These tests are the primary regression suite for the Prisma Next CLI's database
pnpm test:journeys
```

`init-journey.e2e.test.ts` (the 4-cell target × authoring pack+install matrix) is excluded from `pnpm test:journeys` and `pnpm test` unless `RUN_INIT_JOURNEY=1` is set; it runs nightly via `pnpm test:init-journey` (see `.github/workflows/integration-nightly.yml`).

## Test files

### Happy paths

| File | What it covers |
|---|---|
| `init-journey.e2e.test.ts` | **`prisma orm init` inner loop** across all four (target × authoring) cells: scaffold, pack + real install against workspace tarballs, emit, plan, self-emit, apply, run user code. Nightly-only — excluded from PR runs unless `RUN_INIT_JOURNEY=1` |
| `greenfield-setup.e2e.test.ts` | New project with empty database: emit a contract, dry-run init to preview operations, apply init, confirm idempotency on re-run, verify marker and schema (`db verify`, `db verify --schema-only`, `db verify --strict`), inspect the live schema with `db schema`, and check JSON output variants of full and schema-only verify |
| `composite-pk-greenfield.e2e.test.ts` | **Composite primary key greenfield**: emit a PSL contract for a junction table, dry-run and apply `db init`, inspect the live Postgres primary-key constraint order, verify duplicate inserts fail on that constraint, then round-trip through `contract infer` and schema verification |
| `db-schema-discovery.e2e.test.ts` | **Live schema discovery**: inspect an unmanaged database with `db schema`, apply manual DDL, inspect again with `db schema --json`, and confirm the command stays read-only throughout |
Expand All @@ -33,10 +36,9 @@ pnpm test:journeys
| File | What it covers |
|---|---|
| `rollback-cycle.e2e.test.ts` | **Rollback cycle (P-2)**: C1→C2→C1 creates a cycle. `findLeaf` fails with `NO_TARGET`. Plan with `--from` bypasses cycle, apply recovers |
| `converging-paths.e2e.test.ts` | **Converging paths (P-3)**: two paths to the same target (C1→C2→C3 and C1→C3 direct). Pathfinder selects shortest path (2 steps not 3) |
| `divergence-and-refs.e2e.test.ts` | **Same-base divergence (P-4)**: two edges from C1 (C1→C2, C1→C3). Status without `--ref` fails with `AMBIGUOUS_TARGET`. Ref-based resolution routes apply to the correct branch |
| `ref-routing.e2e.test.ts` | **Staging ahead via refs (P-5)**: production=C1, staging=C2 on same DB. Apply `--ref staging` advances staging; production unaffected. **Marker ahead of ref (P-6)**: after staging apply, DB at C2 but production ref at C1 — apply fails, status reports ahead-of-ref |
| `adopt-migrations.e2e.test.ts` | **Adopting migrations (P-9)**: DB managed via `db update` (at C2). Baseline migration EMPTY→C2 is no-op. Incremental C2→C3 applies normally. Status shows both migrations applied |
| `data-transform-strategies.e2e.test.ts` | **Planner-assisted dataTransform strategies**: one scenario per Postgres call strategy (NOT NULL backfill, nullable tightening, text→int4 type change). Planner emits placeholder stubs, the test fills them in, re-emits in-process, applies, and asserts data + column shape |
Comment thread
coderabbitai[bot] marked this conversation as resolved.
| `diamond-convergence.e2e.test.ts` | **Diamond convergence**: Two environments (staging, production) diverge from C1 via independent branches (C1→C2→C3 and C1→C4), then converge to C5. Uses two PGlite instances with separate configs sharing the same migration graph on disk. Verifies both DBs reach C5 via their respective merge migrations and status shows 0 pending for both refs |
| `interleaved-db-update.e2e.test.ts` | **Interleaved db update + migrations**: User on migrations (∅→C1→C2) runs `db update` to C3 instead of `migration plan`. Retroactive `migration plan` creates the C2→C3 edge, `migration apply` is a noop (DB already at C3). Future migrations (C3→C4) resume normally. Documents that `migration plan` is offline (uses latest migration target, not DB marker) |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
migrationStatusAppSpace,
parseJsonOutput,
parseMigrationStatusJson,
planMigrationAndSelfEmit,
runContractEmit,
runDbUpdate,
runMigrate,
runMigrationPlanAndEmit,
runMigrationStatus,
setupJourney,
swapContract,
Expand Down Expand Up @@ -51,7 +51,7 @@ withTempDir(({ createTempDir }) => {
expect(update1.exitCode, 'O.02: db update C2').toBe(0);

// O.03: plan baseline migration EMPTY→C2 (current contract)
const planBaseline = await runMigrationPlanAndEmit(ctx, ['--name', 'baseline', '--json']);
const planBaseline = await planMigrationAndSelfEmit(ctx, ['--name', 'baseline', '--json']);
expect(planBaseline.exitCode, 'O.03: plan baseline').toBe(0);
const baselineResult = parseJsonOutput<{ to: string; noOp: boolean }>(planBaseline);
expect(baselineResult.noOp, 'O.03: baseline is not a plan-noop').toBe(false);
Expand All @@ -73,7 +73,11 @@ withTempDir(({ createTempDir }) => {
swapContract(ctx, 'contract-phone-bio');
const emit2 = await runContractEmit(ctx);
expect(emit2.exitCode, 'O.05: emit C3').toBe(0);
const planIncremental = await runMigrationPlanAndEmit(ctx, ['--name', 'add-bio', '--json']);
const planIncremental = await planMigrationAndSelfEmit(ctx, [
'--name',
'add-bio',
'--json',
]);
expect(planIncremental.exitCode, 'O.05: plan C2→C3').toBe(0);
const incrementalResult = parseJsonOutput<{ from: string; to: string }>(planIncremental);
expect(incrementalResult.from, 'O.05: from C2').toBe(c2Hash);
Expand Down
91 changes: 0 additions & 91 deletions test/integration/test/cli-journeys/converging-paths.e2e.test.ts

This file was deleted.

This file was deleted.

Loading
Loading