update-sqlx
БесплатноЗапускает вложенные скриптыНе проверенHow to safely update SQLx offline query cache. MUST use when SQL queries change.
от windmill-labs★ 18 798 звёзд на GitHubОб этом скилле
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".
Queries Inside Tests Need --all-targets, Which Fails In A CE Checkout
prepare only caches queries in code it compiles, and --workspace alone does not
compile test targets. A sqlx::query! inside tests/*.rs therefore gets no entry, and CI
fails on the test target with the usual "no cached data" error even though the lib built
clean. SQLX_OFFLINE=true cargo check --workspace --all-targets is what reproduces it.
Adding --all-targets caches them — and, in a CE checkout, aborts partway through:
backend/tests/otel.rs imports windmill_common::otel_ee, which exists only behind the
private feature, so the compile dies after prepare has already emptied .sqlx/.
Observed: 2435 → 4 entries, error: cargo check failed with status: exit status: 101.
Do not fight it — the abort is a pre-existing EE gap, not something your change caused. Take the entries you need and put the backup back:
bash .agents/skills/update-sqlx/sqlx-cache.sh backup
cd backend
DATABASE_URL=<this worktree's db> \
cargo sqlx prepare --workspace -- --workspace --features all_sqlx_features --all-targets
# expected to fail; it still wrote the entries it got to before dying
cd ..
bash .agents/skills/update-sqlx/sqlx-cache.sh newq # prints each added query
bash .agents/skills/update-sqlx/sqlx-cache.sh restore # backup back, added entries grafted on
Read what newq prints before running restore — it shows each added entry's query
field, and every one should be yours. The set is small (one per new test query); anything
else in there means the run got further than you think.
Then verify both targets, since the lib passing says nothing about the tests:
SQLX_OFFLINE=true cargo check --workspace --features all_sqlx_features # lib
SQLX_OFFLINE=true cargo check -p <your-crate> --all-targets # tests
The Problem
cargo sqlx prepare --workspace deletes all existing cache files and regenerates only the ones found in the current compilation. If you don't compile with every feature flag (especially private for EE files), you will silently delete EE query caches, breaking CI for enterprise tests.
The standard ./update_sqlx.sh script tries to compile with all features, but it often fails locally because the EE symlinks can be out of sync with main.
Safe Procedure
Always preserve the existing EE caches from origin/main. Use this workflow:
cd backend
# 1. Restore the full cache from main (includes EE caches)
git checkout origin/main -- .sqlx/
# 2. Run prepare with OSS features (what compiles locally)
# This regenerates OSS caches to match your code changes.
cargo sqlx prepare --workspace -- --workspace --features all_sqlx_features
# 3. Restore any EE caches that were deleted in step 2.
# These are files present in origin/main but missing after prepare.
git ls-tree origin/main backend/.sqlx/ \
| awk '{print $4}' | sed 's|backend/\.sqlx/||' | sort > /tmp/main_files.txt
find backend/.sqlx -name "*.json" -printf '%P\n' | sort > /tmp/current_files.txt
comm -23 /tmp/main_files.txt /tmp/current_files.txt > /tmp/missing_files.txt
while read f; do
git show "origin/main:backend/.s
Установить update-sqlx в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл update-sqlx?
How to safely update SQLx offline query cache. MUST use when SQL queries change.
Как установить скилл update-sqlx?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл update-sqlx запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic