Getting started#
Set up Rehearsal in an existing project to test migrations against a disposable local database. Normal setup and rehearsal commands never connect to a hosted database. To experiment without your project, use the synthetic tutorial.
OS-specific setup files (optional)#
Readable helpers are available for Windows / WSL 2, macOS and Linux. They check prerequisites by default. Explicit install options use existing tools; helpers do not install Node/Docker or start a database. Read their shared behavior before using an install option.
Windows: use a WSL 2 Linux workspace#
Run Rehearsal inside WSL 2, using Linux Node, project files and Docker. Native Windows database execution is unsupported.
Follow Microsoft's WSL installation guide to prepare a WSL 2 Linux distribution.
Keep the project in the distribution's Linux filesystem, such as
/home/your-name/projects/app, rather than/mnt/cor a Windows-mounted drive.Install supported Linux Node/npm and configure a Docker-compatible Linux engine. In the Linux terminal, check:
bashnode -p "process.platform" pwd docker info --format '{{.OSType}}'Both platform results must be
linux;pwdmust name a Linux-filesystem path.For VS Code, install Microsoft's WSL extension and run
code .from that directory. Confirm the window's WSL indicator, then install Rehearsal into the Linux extension host.Continue below in that Linux terminal.
WSL compatibility remains a preview. Its exact target and editor support boundaries are in Compatibility. Do not substitute a hosted database to make setup pass.
The following steps use PostgreSQL or Supabase. For other workflows, follow SQLite setup, Prisma Migrate 7 or Prisma 8 RC compiled PostgreSQL. These are separate profiles with their own requirements and limits.
1. Check the required tools#
Use Node.js 22, 24 or 26 and npm; Node.js 24 LTS is recommended. Start your Docker-compatible engine, then check:
node --version
npm --version
docker infoFor Supabase, install the supported Supabase CLI version listed in Compatibility. For PostgreSQL, download the reviewed local image once:
docker pull postgres:17-alpineRehearsal uses that image with downloads disabled during a rehearsal.
2. Install and open the guide#
From the directory containing your application's package.json:
npm install --save-dev @rehearsal-db/core
npx rehearsalAn ordinary npm install creates rehearsal.config.mjs, local runtime configuration
and required ignore entries when the application root is unambiguous. Existing files
are never replaced. Review the migration directory, application start/proof commands,
ports and any CHECK markers.
If install scripts were disabled or setup could not identify one application, choose Set the stage and approve its setup preview. If a supported nested config already exists, keep using the reported path or follow the explicit relocation guide.
Optional release checks contact npm only after your choice. Not now makes no request; see update preferences to change that choice later.
Choose a proof command that tests the behavior affected by your migration. For local Google or GitHub sign-in, follow Supabase authentication to configure the ignored credential file and callback; keep credentials out of tracked files.
3. Prepare safe baseline inputs#
A baseline is the locked starting point restored before each rehearsal. Start with small synthetic data, never raw production data.
| Input | Purpose |
|---|---|
| Records | Safe NDJSON rows, one JSON object per line |
| Migration ledger | Historical migrations represented by those rows |
| Sanitization policy | A reviewed decision for every included table and column |
| Storage manifest | Optional approved Supabase Storage files |
For example:
{ "table": "widgets", "row": { "id": 1, "name": "Synthetic Widget" } }The guide discovers conventional project-local files such as
rehearsal/sanitized-data.ndjson and rehearsal/migration-ledger.json without printing
row values. Then:
- Prepare the script creates a draft sanitization policy.
- Review the script asks you to classify every included table and column.
- Create the baseline validates and activates the reviewed inputs.
Undecided policy fields block activation. The ledger must match the exact historical SQL represented by the data; generate real-project history through reviewed project tooling. See Baselines for formats and the tutorial for complete synthetic inputs.
4. Reach READY#
Follow the guide's recommended action through its four stages until it reports READY.
The same prerequisite check is available directly:
npx rehearsal doctorIf it reports NOT READY, fix the named problem and retry. Do not bypass checks or
add a hosted connection string.
5. Run the rehearsal#
Choose Run a rehearsal, review the exact candidate list and approve it. Rehearsal restores the baseline, applies only approved migrations, verifies the local database and runs your configured application proof. By default it then stops the app it launched and its database targets, retaining their data. The baseline is unchanged.
Production-shaped preparation is a separate, explicitly approved workflow.
Never place source credentials in the runtime configuration. In that workflow,
refresh obtains a newly verified copy; reset restores the baseline you already have.
6. Use the sandbox and clean up#
Choose Open the sandbox app, or run:
npx rehearsal openUse the printed local URL until you press Ctrl+C. By default the app and database
targets then stop, retaining database and Storage edits for your next open session.
- Verify checks the current runtime.
- Reset discards runtime edits and restores the baseline.
- Stop stops services while retaining local state.
- Discard removes this project's disposable runtime and volume.
For retention settings, resource cleanup or interruption recovery, see
Runtime lifecycle. Press Ctrl+Z at a guided prompt to exit
the whole session without leaving a suspended process.
Command-line setup#
Scripts and CI can use explicit commands:
npx rehearsal setup --target=postgresql --write
npx rehearsal doctor
npx rehearsal candidates
npx rehearsal run --confirm-candidates=PASTE_DIGEST_HEREReplace postgresql with supabase when needed. See CLI commands for
flags, confirmation digests and automation contracts.
If setup or an upgrade is interrupted#
Keep your existing config and .rehearsal/. Start with:
npx rehearsal doctor
npx rehearsal initsetup --write creates missing files and ignore entries without replacing existing
configuration. An invalid config is left intact: back it up before generating a new
one and copying your reviewed choices across. After an upgrade, init shows optional
settings missing from your existing config.
For a failed dependency update, preserve the config, baseline and lockfile while restoring dependencies with your package manager. For ports, credentials or low disk space, follow the matching troubleshooting entry.
Files Rehearsal creates#
rehearsal.config.mjs— reviewed project configuration.rehearsal/— ignored baselines, runtime files and receipts.rehearsal/runtime.env— generated local-only application variablesinfrastructure/rehearsal/supabase/config.toml— Supabase-only local configuration
Keep .rehearsal/ out of source control, including synthetic data.