sqlx-index-migrations
Skill96 starsChanged 30 days agoApache-2.0View on GitHub
Create or review control-layer index migrations using SQLx, including concurrent DDL, prebuilt indexes, and follow-up definition validation and comments.
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use SQLx migrations as the single source of index DDL.
- Very specific: line 14
Start each concurrent create/drop file with exactly -- no-transaction.
- Very specific: line 20
Follow a create with a normal transactional migration that validates the index, then adds COMMENT ON INDEX explaining its query/access …
- Very specific: line 27
Use *add_batch_owner_page_index* and *validate_batch_owner_page_index* in fusillade-arsenal/migrations/ as examples.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SQLx index migrations
Use SQLx migrations as the single source of index DDL. Predeploy builds execute those same files; do not duplicate the DDL in standalone scripts. Existing predeploy scripts are historical examples, not the preferred pattern.
File structure
- Start each concurrent create/drop file with exactly
-- no-transaction. The older-- sqlx:no-transactionspelling found in this repo is not recognized by SQLx 0.8. - Include one executable statement per concurrent file. Put
COMMENT ON, validation, and other operations elsewhere: disabling SQLx's transaction does not prevent a multi-statement batch from creating an implicit transaction. - Follow a create with a normal transactional migration that validates the index,
then adds
COMMENT ON INDEXexplaining its query/access pattern and issue. - Reject missing, invalid, not-ready, and wrong-definition indexes. Check the
target table/schema, method, uniqueness, keys and ordering, included columns,
and predicate as applicable.
IF NOT EXISTSonly checks the name and can skip an unusable remnant of an interrupted build.
Use *add_batch_owner_page_index* and *validate_batch_owner_page_index* in
fusillade-arsenal/migrations/ as examples. The wrong-order regression is in
fusillade-arsenal/src/postgres/batch_list.rs. Paths are repo-root-relative.
Repository integration
- Migration directories:
dwctl/migrations/andfusillade-arsenal/migrations/. Respect Fusillade's dedicated-database and shared-fusillade-schema modes; resolve objects using the runner's search path rather than assumingpublic. - Preserve applied migration bytes. For new Fusillade up/down files, add SHA-384
entries to
.github/fixtures/fusillade-migration-sha384.txt; never rewrite old entries to accommodate changes. Check withpython3 .github/scripts/test-fusillade-migration-checksums.py. - Validate through the actual SQLx runner on both fresh and correctly prebuilt states, plus rejection of invalid and wrong-definition indexes. Executing the files only through psql misses SQLx transaction and bookkeeping behavior.
Migrations are applied by dwctl migrate (a pre-rollout Job in deployments,
startup in local development); see docs/migrations.md for the runner and for
the recoverable sequence for concurrent builds: create, then a separate
-- no-transaction REINDEX INDEX CONCURRENTLY file, then the validation and
comment file, with numbering room between them. The reindex step turns an
interrupted build's INVALID index into a valid one on the next run, so no repair
lives outside the migration files.
For populated deployments that must prebuild, run the concurrent file separately on a direct connection in autocommit mode with the intended database/search path, then the validation/comment file, then ANALYZE the affected table before deploying dependent queries. The runner skips the existing build, validates it again, and records it normally; do not manually mark the prebuild as applied. If validation fails, inspect and repair the specific index before proceeding.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- rust-test-efficiencySkill
- sqlx-queriesSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

