
Update Sqlx
How to safely update SQLx offline query cache.
Install
npx skills add windmill-labs/windmill --skill update-sqlx -g -a claude-code -y- Repository
- windmill-labs/windmill18.4k
- Category
- Data and ML
- Updated
- 3d ago
- License
- See repository
- Context cost
- Mediumabout 1,708 tokens
- Runs scripts
- Yes, review before use
What it does
How to safely update SQLx offline query cache. MUST use when SQL queries change.
SQLx Offline Query Cache
Windmill uses SQLX_OFFLINE=true in CI, which requires all sqlx::query! / sqlx::query_as! macros to have matching cached query data in backend/.sqlx/.
When to Run
Run after adding or editing a SQL query in Rust source. Without it, CI fails with:
error: `SQLX_OFFLINE=true` but there is no cached data for this query
Do NOT run it when a change only removes queries. The cache is already complete for
CI; all that is left are orphaned entries, which are cosmetic and never break a build.
Running prepare to tidy them risks destroying the cache for no gain. Delete them
offline instead: for each .sqlx/query-*.json, normalize its query field (strip \
line-continuations, collapse whitespace) and check whether it still appears in any .rs
file. That detector reports ~48 false positives in a CE checkout, EE queries live in
*_ee.rs symlinks it cannot read, so filter to the tables your change touched and
delete only those.
Before You Run Anything
- Back the cache up.
preparedeletes.sqlx/before regenerating, so any compile failure leaves it gutted (observed: 2350 → 142 entries).
Its state is per-worktree, so a sibling worktree runningbash .agents/skills/update-sqlx/sqlx-cache.sh backupprepareat the same time cannot overwrite your backup. - Point
DATABASE_URLat THIS worktree's database.preparecompiles everysqlx::query!against the live database. Another worktree's DB lacks your migrations, so every new-table query fails and takes the cache down with it. The symptom isrelation "<your_new_table>" does not exist, that is a wrongDATABASE_URL, not a broken query. See AGENTS.md → "Per-worktree ports and database".
