Skip to main content

## MIGRATION_022

# Constant MIGRATION_022

Source

    const MIGRATION_022: &str = r#"
    CREATE VIRTUAL TABLE IF NOT EXISTS people_fts USING fts5(
        name,
        overview,
        content='people',
        content_rowid='rowid'
    );

    CREATE TRIGGER IF NOT EXISTS people_ai AFTER INSERT ON people BEGIN
        INSERT INTO people_fts(rowid, name, overview)
        VALUES (new.rowid, new.name, new.overview);
    END;

    CREATE TRIGGER IF NOT EXISTS people_ad AFTER DELETE ON people BEGIN
        INSERT INTO people_fts(people_fts, rowid, name, overview)
        VALUES('delete', old.rowid, old.name, old.overview);
    END;

    CREATE TRIGGER IF NOT EXISTS people_au AFTER UPDATE ON people BEGIN
        INSERT INTO people_fts(people_fts, rowid, name, overview)
        VALUES('delete', old.rowid, old.name, old.overview);
        INSERT INTO people_fts(rowid, name, overview)
        VALUES (new.rowid, new.name, new.overview);
    END;

    -- Backfill for rows cached before this index existed.
    INSERT INTO people_fts(people_fts) VALUES('rebuild');
    "#;

Expand description

Full-text index over `people`, mirroring `items_fts`.

People live in their own table (migration 009) rather than in `items`, and had no FTS index at all — so the People group UR-060 requires could only ever be filled by the server leg of search. With the local index now answering first, an actor’s name has to be findable offline too.

TRACES: UR-065, UR-060 | DR-111