-- Shareable group invite links. A token is a bearer capability: anyone with an
-- account who has the link can join the group. Revoke by deleting the row(s).
-- The server still only ever holds group METADATA — message content stays E2E.

CREATE TABLE group_invites (
  token       TEXT PRIMARY KEY,
  group_id    TEXT NOT NULL REFERENCES groups(id) ON DELETE CASCADE,
  created_by  TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
  created_at  INTEGER NOT NULL
);
CREATE INDEX idx_group_invites_group ON group_invites(group_id);
