-- Block H — privacy compliance. -- -- Adds the columns needed for: -- - Right to erasure (DELETE /me): soft-delete first, hard-delete via -- a future cron after a 30-day grace window so an accidental click -- is recoverable. -- - Terms / privacy-policy acceptance gate (set on signup; older -- accounts re-prompted via the frontend on next login). ALTER TABLE users ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMPTZ, ADD COLUMN IF NOT EXISTS terms_accepted_at TIMESTAMPTZ, ADD COLUMN IF NOT EXISTS privacy_policy_accepted_at TIMESTAMPTZ; -- Most lookups (login, /me, etc.) want to exclude soft-deleted users. -- A partial index keeps the active subset fast without bloating writes -- for the rare deleted rows. CREATE INDEX IF NOT EXISTS idx_users_active_email ON users(email) WHERE deleted_at IS NULL;