Indexes: add index / drop index, persistence, display (ADR-0025)

Implement ADR-0025 — indexes as a DSL DDL feature.

- Grammar: `add index [as <name>] on <T> (<cols>)`, `drop index
  <name>` / `drop index on <T> (<cols>)`, plus a `--cascade`
  flag on `drop column`.
- db.rs: index operations over the engine's native index
  catalog (no metadata table). The rebuild-table primitive now
  captures and recreates indexes, so `change column` and the
  relationship operations no longer silently drop them.
- `drop column` refuses an indexed column unless `--cascade`,
  which drops the covering indexes and reports each.
- Persistence: additive `indexes:` list in `project.yaml`
  (version unchanged); round-trips through rebuild/export/import.
- Display: an `Indexes:` section in the structure view and a
  nested tables/indexes items panel (S2).

Reconciles requirements.md (C3 index portion, S2 satisfied)
and CLAUDE.md. 1038 tests passing (+31), clippy clean.
This commit is contained in:
claude@clouddev1
2026-05-16 00:15:55 +00:00
parent 41043d686b
commit 0dc159fd7e
35 changed files with 2155 additions and 73 deletions
+16 -10
View File
@@ -26,12 +26,12 @@ repo is pushed).
## Test baseline
After ADR-0024 full implementation + the handoff-14 cleanup
pass: **1006 passing, 0 failing, 1 ignored** (`cargo test`
the one ignored test is a long-standing `` ```ignore ``
doc-test in `src/friendly/mod.rs`). Clippy clean with the
nursery lint group enabled. (Earlier reference point, after
B2/C2: 449 passing.)
After ADR-0025 (indexes): **1037 passing, 0 failing, 1
ignored** (`cargo test` the one ignored test is a
long-standing `` ```ignore `` doc-test in
`src/friendly/mod.rs`). Clippy clean with the nursery lint
group enabled. (Earlier reference points: 1006 after ADR-0024
+ the handoff-14 cleanup; 449 after B2/C2.)
---
@@ -47,11 +47,12 @@ B2/C2: 449 passing.)
- [ ] **S1** Three-region layout: items list (left), output
panel (right), input field (bottom).
- [ ] **S2** Items list shows tables and per-table indexes;
- [x] **S2** Items list shows tables and per-table indexes;
designed to extend to additional element kinds (relations,
views, etc.) without restructuring.
*(Progress: tables are listed live from the database; indexes
pending alongside C3 index support.)*
*(ADR-0025: the items panel renders a nested list — each
table with its index names indented beneath it. The nested
model is the extension point for future element kinds.)*
- [ ] **S3** Output panel renders a visualization of the
currently selected item and supports multiple tabs.
- [ ] **S4** Hint area below the input field; keyboard-toggleable
@@ -130,7 +131,9 @@ B2/C2: 449 passing.)
FK with `ON DELETE` / `ON UPDATE` actions done (ADR-0013) —
declared via `add 1:n relationship`; symmetric outbound +
inbound view in the structure renderer; type compatibility
validated at declaration via `Type::fk_target_type()`. Index,
validated at declaration via `Type::fk_target_type()`.
Indexes done (ADR-0025) — `add index` / `drop index`,
rebuild-preserving, persisted in `project.yaml`.
`NOT NULL`, `UNIQUE`, `CHECK`, `DEFAULT` still pending.)*
- [~] **C3a** Modify relationship: `modify relationship <name>
[on delete <action>] [on update <action>]`. Users can achieve
@@ -339,6 +342,9 @@ B2/C2: 449 passing.)
- [ ] **QA1** `EXPLAIN QUERY PLAN` is run on demand for queries;
output is rendered as an annotated tree highlighting full
scans, index use, and join order.
*(Unblocked by ADR-0025: indexes now exist, so a plan for
`show data <T> where <col>=<val>` visibly changes with an
index. Still needs the QA2 rendering ADR.)*
- [~] **QA2** Plan rendering specifics (tree layout, annotation
taxonomy, colour scheme) — design and ADR pending.