What the agent does
The agent reads the schema and the migrations it produced, because an updatedAt column that never changes is a schema bug, not a query bug. In an app laid out like shadcn-ui/taxonomy, prisma/schema.prisma targets mysql and declares updatedAt DateTime @default(now()) @map(name: "updated_at") on Account, User and Post, with no @updatedAt attribute on any of them. prisma/migrations/20221021182747_init/migration.sql shows what that became: updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) and nothing else, no ON UPDATE clause, so a row's updated_at is set once at insert and stays there through every db.user.update in app/api/users/[userId]/route.ts and every db.post.update in app/api/posts/[postId]/route.ts. Session and VerificationToken carry no timestamps at all. The client is @prisma/client 4.13.0 in pnpm-lock.yaml, generated by the postinstall script, and prisma/migrations/migration_lock.toml pins the provider to mysql.
The fix is one attribute per model, in the right place. @updatedAt tells the Prisma client to write the current time on every update, updateMany and upsert, and it composes with @default(now()), so the insert behaviour is unchanged and the agent keeps both. It adds the attribute to the three models that have the column and leaves Session and VerificationToken alone: NextAuth's adapter owns those tables, and adding columns it does not know would be a different change. Because the stamping happens in the client and not in MySQL, there is no SQL to migrate: the agent runs prisma migrate diff --from-migrations prisma/migrations --to-schema-datamodel prisma/schema.prisma with a shadow database and shows that this change adds no statements.
That diff turns up something the agent reports rather than fixes. prisma/migrations/20221118173244_add_stripe_columns/migration.sql drops the three foreign keys the first migration created, on accounts, posts and sessions, as a PlanetScale deployment requires, while the schema still declares the relations without relationMode = "prisma". The diff therefore lists those constraints as pending before and after the attribute is added. The agent quotes the diff in the pull request, names the two options (set relationMode to match the migrations, or re-add the keys), and changes neither, since the task is timestamps.
Proof comes from a database, not from reading. In its sandbox the agent starts MySQL in a container, points DATABASE_URL at it, runs pnpm install (which generates the client) and prisma migrate deploy to apply both migrations, then runs a short script with the generated client: create a user, read updatedAt, wait one second, update the name the way the users route does, read again, and assert the second value is later. It runs the same script before the attribute is added to show the two values equal, and quotes both runs. pnpm lint runs last, since the repository has no test suite to run.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Fix the updatedAt fields in this Prisma schema. Read prisma/schema.prisma, every file under prisma/migrations, lib/db.ts, app/api/users/[userId]/route.ts and app/api/posts/[postId]/route.ts first. Add @updatedAt to every model whose updatedAt field has only @default(now()); keep the default and the @map. Do not add timestamps to the NextAuth models that have none. Start a MySQL container, set DATABASE_URL, run pnpm install and prisma migrate deploy, and prove the change with a script that creates a user, updates its name and reads updatedAt before and after, run once before and once after the schema change. Run prisma migrate diff from the migrations to the schema with a shadow database and quote it; report any pending differences unrelated to this change without fixing them. Run pnpm lint. Open a pull request.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- 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.
- 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.
- 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
What comes back is a pull request that changes prisma/schema.prisma on three lines and nothing else in the application, with the proof script added under a scripts/ directory the reviewer can delete or keep. The description quotes the script's output before the change, where the two updatedAt values are equal, and after it, where the second is later, and the prisma migrate diff output showing no statement for the attribute.
The description also carries the foreign-key finding from the diff as a note with both options spelled out, so the reviewer learns about the drift between the schema and the migrations from this pull request even though it does not touch it.
Before merging, a reviewer checks that no code relied on updatedAt staying equal to createdAt, which a search for updatedAt in the repository answers, and regenerates the client in their own environment with pnpm install.
Run it on every Prisma schema change
A pull request that edits prisma/schema.prisma is the moment to catch the next field declared with a default and no @updatedAt. A github trigger on pull_request.opened and pull_request.synchronize starts a run for each pull request a person opens, with a prompt asking the agent to read the schema diff on that branch and post one review comment per DateTime field named updatedAt that lacks the attribute, and nothing when there is none. The trigger adds the pull request after the prompt, so the prompt names no branch.
Each run checks out the pull request's branch in its own sandbox and reads only the schema and migrations, so it finishes quickly and never needs the database. A pull request a bot opens never fires the trigger, so a handler on the reader's server starts those runs with the …/pull/<n> URL in resources and a request_id that is a UUID v5 of the head commit SHA.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
The bug is invisible in code review: updatedAt DateTime @default(now()) reads as correct, the migration applies cleanly, and every row carries a plausible timestamp that happens never to change. Finding it means reading the generated SQL and knowing which attribute the client needs. In a Rush sandbox the agent reads the migration, adds the attribute, and proves the before and after against a real MySQL with the generated client, and the record keeps both runs.
The same run reports the unrelated drift the diff exposes, with the evidence, instead of either fixing it unasked or hiding it. Across every Prisma project a team keeps, the job runs in parallel, one sandbox and one pull request each, and each pull request's diff is the one its own migrations produce.
Frequently asked questions
Why is there no migration in the pull request?
Because @updatedAt is applied by the Prisma client at update time, not by the database. The column, its type and its DEFAULT CURRENT_TIMESTAMP(3) stay as the first migration created them, and prisma migrate diff shows no statement for the change.
Will existing rows get a new updatedAt?
No. Rows keep the value they have until the next update through the client, which then stamps them. If a backfill is wanted, it is a separate UPDATE setting updated_at to created_at, which the agent leaves out since the two are already equal for every row the old schema wrote.
What about updates made with raw SQL or outside Prisma?
They are not stamped, since the attribute lives in the client. A trigger or an ON UPDATE CURRENT_TIMESTAMP(3) clause would cover those, but Prisma does not generate either, and adding one by hand would make the migrations and the schema disagree further.
Should the foreign-key drift be fixed in the same change?
The agent says no and leaves it. The migrations dropped the keys on purpose for PlanetScale, and the right fix is a decision between relationMode = "prisma" and re-adding the constraints, which a maintainer makes with the hosting in mind. The pull request gives them the diff to decide from.