Skip to content

store: back remaining relational invariants with DB constraints #72

Description

@kostyafarber

Follow-up from the store constraint audit on refactor-electron-side. Foreign keys are enforced (PRAGMA foreign_keys = ON per connection) and ownership edges/ordering are constraint-backed, but two invariants are app-enforced only:

  1. glyph_layers needs UNIQUE(glyph_id, source_id) — "one layer per glyph per source" has no DB backing. With eager layer creation (new source → layer per glyph, new glyph → layer per source, VF-2) a bug could create duplicate layers silently and reads would pick arbitrary rows.

  2. sources.name needs a unique index — duplicate source names are rejected in Rust validation only.

Open question (deliberate non-constraint for now): glyphs.name is not unique. Identity is id; names are editable display data — but the renderer's name-keyed directory assumes no collisions. Decide when the rename vocabulary (updateGlyphIdentity) returns; a unique index would need swap-safe rename handling.

Pre-release policy applies: edit the baseline schema in crates/shift-store/src/schema.rs in place, no migrations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions