apso migrate
Detect schema changes, generate migration SQL, and test it against a local PGlite sandbox. No Docker or external database required.
Usage
apso migrate
apso migrate --apply
apso migrate --reset
apso migrate --sqlOptions
| Option | Description | Default |
|---|---|---|
--apply | Update local schema snapshot after a successful migration test | false |
--reset | Reset the sandbox (clear snapshot and PGlite data) | false |
--sql | Output raw SQL statements only (for piping to files or review) | false |
How it works
The migration sandbox maintains a snapshot of your last-known schema state in .apso/sandbox/schema-snapshot.json. When you run apso migrate:
- Compares your current
.apsorcagainst the snapshot to detect changes - Builds the previous schema in an in-process Postgres database (PGlite)
- Generates the migration SQL needed to move from the old schema to the new one
- Executes the migration against the local database to verify it works
- Reports the results with the SQL statements
If the migration succeeds locally, you know the SQL is valid before it touches any real database.
Examples
Check for schema changes and preview the migration:
apso migrateOutput:
Schema changes detected. Running migration sandbox...
Migration SQL (up):
---
ALTER TABLE "project" ADD "priority" integer NOT NULL DEFAULT 0;
CREATE TABLE "label" ("id" SERIAL PRIMARY KEY, "name" text NOT NULL);
---
2 statement(s) generated and tested.
Migration validated against local PGlite.
Run with --apply to update the snapshot.Apply the migration (update the snapshot so future runs compare against the new state):
apso migrate --applyPipe raw SQL to a file:
apso migrate --sql > migration.sqlReset the sandbox to start from a clean state:
apso migrate --resetFirst run
On the first run, there is no previous snapshot. The sandbox generates CREATE TABLE statements for all entities and validates them. Run with --apply to establish the initial baseline.
Notes
- PGlite runs entirely in-process — no Docker, no external Postgres installation needed
- The snapshot file is stored at
.apso/sandbox/schema-snapshot.json apso deployruns the migration sandbox automatically before deploying