create_index
Create an index on a PostgreSQL table to improve query performance. Supports concurrent non-blocking builds, unique indexes, and various methods.
Instructions
[WRITE][risk=medium] Create an index. Reversible: undo drops the created name.
Supports CONCURRENTLY (non-blocking build). The created name is returned so
the harness records an undo that drops exactly this index. Pass dry_run=True
to preview. Alternatively pass ``definition`` (a captured pg_get_indexdef
statement — this is how drop_index's undo descriptor replays) INSTEAD of
table/columns.
Args:
table: Table to index (optionally schema-qualified). Required unless
``definition`` is given.
columns: Column names to index. Required unless ``definition`` is given.
name: Index name (auto-generated from table+columns when omitted).
unique: Create a UNIQUE index.
concurrently: Build with CONCURRENTLY (no table lock).
method: Index method — btree/hash/gist/gin/brin/spgist (default btree).
definition: A full CREATE [UNIQUE] INDEX statement to execute verbatim
(shape-validated). Mutually exclusive with table/columns.
dry_run: If True, preview without creating.
target: Target name from config; omit for the default.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | ||
| table | No | ||
| method | No | ||
| target | No | ||
| unique | No | ||
| columns | No | ||
| dry_run | No | ||
| definition | No | ||
| concurrently | No |