junior upgrade
junior upgrade applies pending Drizzle migrations to the database configured
by DATABASE_URL. The scaffolded vercel.json runs it before pnpm build on
every Vercel deploy, so production migrates itself. Run it by hand for a local
database, for a host whose build command does not run it, or for the bridge
procedure below.
For Neon, it connects to the direct endpoint: the DATABASE_URL host without
-pooler. It does not read DATABASE_URL_UNPOOLED. The migration lock does not
work through a pooler.
Run the command from your Junior app:
pnpm exec junior upgradeThe command takes no arguments. It migrates the core Junior schema first, then the schemas owned by enabled plugins. Already-applied migrations are recognized as up to date and are not rerun.
Upgrade bridge for older databases
Section titled “Upgrade bridge for older databases”An existing Junior database without core Drizzle migration history must
complete the 0.107.1 upgrade before upgrading to a later release. Before
starting this bridge, block new ingress, drain active and resumable work, stop
all old workers and queue consumers, and keep them stopped until the later
release is ready. If Junior reports this unsupported database state:
- Install
@sentry/junior@0.107.1. - Run
pnpm exec junior upgradeand confirm it completes successfully. - Restore the intended Junior version.
- Run
pnpm exec junior upgradeagain. - Deploy the intended version, then restart workers and reopen ingress.
Fresh databases without Junior tables do not require the bridge release.
Memory plugin databases
Section titled “Memory plugin databases”Through 0.310.0, Memory was the @sentry/junior-memory plugin. A later
junior upgrade keeps the Memory tables and data of a database that ran
every plugin migration. It stops with an error on a database that ran only
some of them. Run pnpm exec junior upgrade with @sentry/junior@0.310.0 and
@sentry/junior-memory@0.310.0 first, then upgrade again.
A database that ran the plugin can roll back to 0.310.0. A database that a later version created cannot roll back to 0.310.0 or earlier: the plugin migrations of 0.310.0 fail on its Memory tables. See Memory.
Native agent-history migration
Section titled “Native agent-history migration”When upgrading from a release that writes agent_step conversation events,
block new ingress, drain active and resumable work, and stop all old workers
before running junior upgrade. Deploy the new runtime before restarting
workers or reopening ingress. The migration rewrites existing history once, so
an old worker that remains active could append a legacy event after the rewrite.
Example output
Section titled “Example output”An already-current database reports its migrations as existing:
Checking database migrations... junior: up to date (8 migrations) junior-github: up to date (4 migrations)Database is up to date (12 migrations).Failure behavior
Section titled “Failure behavior”The command exits nonzero when it cannot connect to SQL, encounters an unsupported pre-Drizzle database, or a migration fails. Treat that as a deploy blocker: correct the reported database or migration error, then rerun the command.
Verification
Section titled “Verification”Confirm that the command exits successfully and lists junior plus each
enabled plugin that owns migrations. The final line reports whether the
database was already current or how many migrations were applied.
Next step
Section titled “Next step”Run junior check before deploying. The deploy build then runs junior snapshot create.