-- Fallback full-text search index (§4.7 / ARCHITECTURE's "Load-bearing
-- indexes" table). Typesense is the primary search path per ADR-007 and
-- isn't wired up yet (needs indexing pipeline + §4.8 query-time ACL
-- filtering) — this GIN index lets libs/messaging's searchMessages() work
-- correctly today via Postgres directly, and doubles as the eDiscovery
-- fallback ADR-007 specifies even once Typesense exists.
--
-- Not modeled in libs/data/schema/*.ts because it's an expression index
-- (on to_tsvector(text), not a column) — drizzle's schema DSL doesn't
-- represent those, so it lives here alongside rls.sql as auxiliary SQL
-- applied after migrations. Idempotent: safe to re-run on every deploy.
create index if not exists messages_text_search_idx
  on messages using gin (to_tsvector('simple', text));
