Expand description
Declarative schema-as-code for mushroomdb.
Schema is a serde-JSON-round-trippable description of the fulltext
indexes, materialized views, and linking rules that should exist in a
database. GraphDb::apply_schema applies the schema idempotently:
items already matching the live database are left untouched (no WAL write),
items that differ are replaced (delete + create), and items absent from the
schema are left in place (no pruning — destructive removal is out of scope
for this plan).
§Application order
- Fulltext indexes are applied first: rules may later benefit from freshly-enabled fulltext state during backfill, even though the current rule predicates do not require it.
- Views are applied second: they are cheaper to backfill than rules and logically independent of rules.
- Rules are applied last. Creating a rule triggers a full backfill of derived edges, which can be expensive for large graphs — document the cost at the call site.
§Update semantics
When a schema item (rule or view) exists in the database but its definition
differs from the one in the schema, it is replaced via delete_X +
create_X. For rules, the create_rule call triggers a full backfill of
derived edges — this can be expensive for large graphs. The re-backfill
cost is inherent to any definition change (the old edge set may not be
valid under the new predicate), so there is no cheaper path in v1.
§No pruning
Items that live in the database but are absent from the schema are left untouched. Destructive removal (“prune items not in the schema”) waits for explicit demand — YAGNI for this plan.
Structs§
- Schema
- A declarative description of the schema that should exist in a database.
- Schema
Diff - The outcome of a single
GraphDb::apply_schemacall.