All jobs

Upgrade Drizzle ORM and Drizzle Kit

Yes. The agent moves drizzle-orm, drizzle-kit and drizzle-zod together, reruns typecheck, tests and migration checks, and opens a pull request with the output.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

Drizzle ships as packages that have to move together, and its version numbers hide upgrades from the usual tooling. In a project like w3cj/hono-open-api-starter, package.json asks for drizzle-orm at ^0.44.4, drizzle-zod at ^0.8.2 and drizzle-kit at ^0.31.4, and pnpm-lock.yaml holds exactly those versions. For a package below 1.0 a caret range admits patch releases only. So pnpm update raises drizzle-orm within 0.44 and stops, and a project that updates every week can sit a minor line behind without any command saying so. The agent reads the registry for each package's latest tag, compares it with the lock, and reads the pre-release tags too so it can say what is coming without installing it.

Before changing anything it records a baseline, because an upgrade can only be blamed for what was green before. Here that means pnpm typecheck, pnpm lint, pnpm test and pnpm build. One of them already fails on the default branch: ESLint reports an unused import of z on the first line of src/db/schema.ts. The agent notes it as existing and leaves it out of the upgrade's diff. It also creates .env from .env.example, since drizzle.config.ts loads src/env.ts and drizzle-kit refuses to start without one.

Then it raises the ranges and reruns everything, reading each check for what it proves. tsc --noEmit is the widest net, since most Drizzle changes that break code break types first. This repository has two places to watch: src/lib/zod-utils.ts casts every schema that drizzle-zod builds to a zod v4 type, and patchTasksSchema in schema.ts sits under a @ts-expect-error comment. If a new drizzle-zod makes that line type-check, TypeScript fails the build for an unused directive, and the right fix is to delete the comment. The twelve tests in tasks.test.ts run real queries through @libsql/client against file:test.db and create that database with pnpm drizzle-kit push, so they exercise the new ORM and the new kit in one pass.

Migration state is checked last, with the upgraded kit. drizzle-kit generate must report no schema changes; a kit that reads the committed snapshot differently would write a migration nobody asked for. drizzle-kit check must pass. The agent then applies the committed migrations with drizzle-kit migrate to a scratch file and compares the resulting table with what push builds. If the kit asks for the snapshots under src/db/migrations/meta to be upgraded to a newer format, the agent runs the command the kit names, commits the result separately and says so. The project's README records two earlier upgrades, of Drizzle and of zod, that each needed code changes, so the agent reads the release notes between the two versions and lists every breaking entry with whether this code uses the affected API.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Upgrade Drizzle in this repository: drizzle-orm, drizzle-kit and drizzle-zod, to the newest stable release of each that work together. Read package.json, the lockfile entries for those three packages and the database driver, drizzle.config.ts, the schema file, the database client module, the env module, the migrations directory with its journal and snapshots, the tests and the README first. Create .env from .env.example. Record a baseline on the untouched branch: typecheck, lint, tests, build, drizzle-kit generate and drizzle-kit check, and list anything that already fails so it is not blamed on the upgrade. Read each package's latest and pre-release tags from the registry and its peer dependency ranges; do not install a pre-release. Remember that a caret range on a 0.x version only admits patch releases, so edit the ranges in package.json and do not rely on the update command. After upgrading, rerun every baseline command. Fix type errors in our code with the smallest change, and remove any @ts-expect-error that the upgrade makes unnecessary. drizzle-kit generate must report no schema changes and must not write a migration; if the kit asks to upgrade the snapshot format, run the command it names and commit that separately. Apply the committed migrations with drizzle-kit migrate to a scratch database file and compare the tables with the ones drizzle-kit push creates. Read the release notes between the old and new versions and list each breaking change with whether this code is affected. Do not change the schema, do not upgrade unrelated packages, and do not fix failures that existed before. Open a pull request with the before and after output of every command.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

A pull request that changes package.json, the lockfile and whatever source lines the new versions required. The description opens with a table: each package, the version before and after, and the registry tag it came from. Under it are the baseline and the after results for typecheck, lint, tests, build, generate and check, with failures that existed before the upgrade marked as such.

Then the breaking-change list from the release notes, one line each, with a verdict: not used here, used and already compatible, or used and changed in this pull request with the file named. Pre-release lines are mentioned by their tag and left uninstalled.

A reviewer checks two things the commands cannot settle. First, that no file under the migrations directory changed unless the description explains a snapshot upgrade; an unexplained new migration means the kit and the schema disagree. Second, that the driver the tests ran against is the one production uses, since a suite that passes on a local SQLite file says little about a hosted database reached over the network.

Run it on every Monday morning

An automation in the Project that holds the repository, with this prompt and a schedule trigger whose cron is 0 8 * * 1 in your timezone, starts one run a week. When the lock already holds the newest stable versions the run ends with a short answer and opens no pull request. It runs as the member who last changed the automation, and its pull request comes from the branch the run pushed.

A dependency bot's version bump does not replace this, and it cannot start it either: a github trigger fires only for work by an owner, member or collaborator of the repository, never for a bot's. For a company with many services on Drizzle, a script on your own server sends this body once per repository to POST /o/{org}/sessions, with that repository in resources and a request_id that is a UUID v5 of the repository's full name and the target drizzle-orm version. A repeated call returns the run already started, and each run reads its own lockfile.

The use case this job follows, with its automation and trigger: Upgrade dependencies weekly.

Why run it on Rush?

The work is a long sequence of installs and checks run twice, and the value is in not skipping one. In its own sandbox the agent can run the full baseline, upgrade, run it all again and apply migrations to a scratch database, without touching the dev.db or the node_modules on anyone's machine. Each command and its output stays in the transcript at GET /o/{org}/sessions/{id}/messages, so the table in the pull request can be checked against what was printed.

Drizzle is also used across many small services in the same company, each with its own lock. One run per repository, started together, turns a release into a set of pull requests that each carry their own proof, in place of one engineer repeating the same steps in every checkout.

Frequently asked questions

Will it move us to the 1.0 pre-release?

No. The prompt limits it to stable releases, and it reads the pre-release tags only to tell you they exist. A move to a new major line changes more than version numbers and deserves its own run with its own prompt.

Why did our weekly update never pick up the new Drizzle minor?

Because of how caret ranges work below 1.0. ^0.44.4 allows 0.44.5 and later patches but not 0.45.0, so an update command stays inside the 0.44 line. The agent edits the range in package.json to get past that.

Does the upgrade change my database?

It should not, and the run checks that. After the upgrade drizzle-kit generate has to find nothing to migrate. If the new kit would write a migration for an unchanged schema, the agent stops and reports the generated SQL instead of committing it.

What if a check was already failing before the upgrade?

It is listed as existing and left alone. In w3cj/hono-open-api-starter, pnpm lint fails on an unused import before any package changes. Mixing that fix into a dependency pull request would make the diff harder to review, so the agent mentions it and moves on.

More Drizzle jobs

More jobs like this: Upgrade dependencies weekly

Keep reading