What the agent does
The agent clones the repository into its own sandbox and reads what the upgrade touches before changing a version. In launchbadge/realworld-axum-sqlx, Cargo.toml asks for sqlx = "0.5" with the features runtime-tokio-native-tls, postgres, uuid and time, and Cargo.lock holds sqlx 0.5.9, time 0.2.27 and uuid 0.8. Those last two are not free choices: sqlx's time and uuid features decode into specific major versions of those crates, so moving sqlx past 0.5 moves time to 0.3 and uuid to 1.x with it. axum 0.3.4 and tower-http 0.2 are left alone; they are a separate upgrade.
Next it finds every place the old APIs are used. The handlers under src/http call sqlx::query!, query_as! and query_scalar! throughout users.rs, profiles.rs, articles/mod.rs, articles/listing.rs and articles/comments.rs, and each of those macros is checked against a live database at compile time. src/http/types.rs wraps OffsetDateTime in a #[derive(sqlx::Type)] newtype, Timestamptz, and serializes it with time 0.2's lazy_format(Format::Rfc3339) and parses it with OffsetDateTime::parse(v, Format::Rfc3339); time 0.3 moved RFC 3339 to format_description::well_known::Rfc3339 and made formatting fallible. src/http/extractor.rs builds JWT expiry from time::Duration::weeks(2) and OffsetDateTime::now_utc(). src/http/error.rs matches sqlx::Error::Database(dbe) and reads dbe.constraint() to map unique violations.
It reads sqlx's changelog for every release between 0.5 and the newest stable one and writes down each breaking change with whether this code hits it, including the split of the combined runtime-tokio-native-tls feature into separate runtime and TLS features. Then it installs and starts Postgres in the sandbox, sets DATABASE_URL and HMAC_KEY the way .github/workflows/rust.yml does, installs sqlx-cli at the same version as the new library, and runs sqlx db setup, which applies migrations/1_setup.sql through 4_article.sql. With the database up, cargo build checks every macro against the real schema, which is the only check that matters for a sqlx upgrade.
Last it runs the same steps CI runs: cargo build, cargo test, and the RealWorld Postman collection from the pinned abonander/realworld commit against cargo run on port 8080. It records each command's output before and after the upgrade, so a failure that existed on the untouched branch is not blamed on the new version, and it pins cargo install sqlx-cli in rust.yml to the version it upgraded to, because an unpinned install takes whatever is newest on the day CI runs.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Upgrade sqlx in this repository from 0.5 to the newest stable release. Read Cargo.toml, Cargo.lock, .github/workflows/rust.yml, the migrations directory, src/http/types.rs, src/http/extractor.rs, src/http/error.rs and every file that calls a sqlx query macro first. Move time and uuid only as far as the new sqlx features require, and do not upgrade axum, tower or tower-http. Read the sqlx changelog for every release in between and list each breaking change with whether this code is affected. Start Postgres in the sandbox, set DATABASE_URL and HMAC_KEY as rust.yml does, install sqlx-cli at the same version as the library and run sqlx db setup, so every query macro compiles against the real schema. Record cargo build, cargo test and the RealWorld Postman collection that rust.yml runs, before and after the upgrade. Fix only what the upgrade breaks, with the smallest change, and keep the JSON timestamp format the API returns today. Pin sqlx-cli in rust.yml to the new version. Open a pull request with the before and after output.",
"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 on its own branch. For this repository the diff changes the sqlx, time and uuid lines in Cargo.toml and the matching Cargo.lock entries, rewrites the Timestamptz serialize and deserialize code in src/http/types.rs for time 0.3, adjusts src/http/extractor.rs and any handler the compiler flags, and pins sqlx-cli in .github/workflows/rust.yml. The description lists each breaking change from the changelog with "affects us" or "does not", and the before and after output of cargo build, cargo test and the Postman run.
The pull request's checks run the repository's own Rust workflow on GitHub, which sets up its Postgres service, builds and runs the Postman collection again. The session transcript has every command from the sandbox with its output, including the compile errors the upgrade produced and how each was fixed.
Before merging, a reviewer checks two things the compiler cannot. First, that created_at and updated_at still serialize as the same RFC 3339 strings the RealWorld clients expect, which the Postman collection exercises. Second, that on_constraint in error.rs still turns a duplicate username or email into the same 422 with "username taken" or "email taken": users.rs matches the constraint names user_username_key and user_email_key, which come from the migrations, on an error type that comes from sqlx.
Run it on every first of the month
Once the big jump is done, keeping sqlx current is a smaller run each time. An automation in the Project that holds the repository, with a version of this prompt that says "upgrade sqlx to the newest stable release if it is not already" and a schedule trigger whose cron is 0 8 1 * * in your timezone, starts one run on the first of each month. When Cargo.lock already has the newest release the run ends with a short answer and opens no pull request.
Each run is capped by the automation's max_runs_per_hour, and it runs as the member who last changed the automation, so its pull request and its cost are attributed to them.
The use case this job follows, with its automation and trigger: Upgrade dependencies weekly.
Why run it on Rush?
A sqlx upgrade cannot be checked without a database, because the query macros talk to Postgres while the code compiles. On a laptop that means pointing DATABASE_URL at a local server, applying migrations to it and hoping its schema matches the migrations. In a Rush sandbox the agent installs Postgres, applies the four migrations to an empty database and compiles against exactly that, so a macro that passes was checked against the schema the repository describes.
The upgrade is also a long chain of builds, and the useful record is all of them. The transcript keeps the baseline build, each compile error after the version change, each fix and the final Postman run, so a reviewer can see that the timestamp format and the constraint errors were tested rather than assumed.
Frequently asked questions
Do I need sqlx's offline mode for this?
No. The agent compiles against a live Postgres in the sandbox, so neither sqlx-data.json nor a .sqlx directory is needed for the upgrade. If your CI builds without a database, ask in input for cargo sqlx prepare and the agent commits the query data in the format the new version uses.
Why does the time crate change too?
sqlx's time feature decodes timestamptz into one major version of the time crate, and releases after 0.5 use time 0.3. Code that names time 0.2 types or formats, like Format::Rfc3339 in types.rs, has to move with it.
Will it upgrade axum at the same time?
No. The prompt keeps axum, tower and tower-http where they are, so the pull request contains only what the sqlx upgrade forces. Upgrading axum from 0.3 is a separate run with its own review.
What if the Postman collection already fails before the upgrade?
The baseline catches that. The agent runs every check on the untouched branch first and lists what already fails in the pull request, so those failures are not blamed on the new sqlx and are not quietly fixed inside the upgrade.
More SQLx jobs
More jobs like this: Upgrade dependencies weekly
- Upgrade Storybook to the Latest Version (Storybook)
- Upgrade Strapi to the Latest Version (Strapi)
- Upgrade Symfony and Its Dependencies (Symfony)