persona-community-5/services/persona-api/cmd/server/migrations/002_add_indexes.sql
jordan f5f3229364
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Add components: service/persona-api, worker/media-worker, app-react/creator-ui
2026-02-24 07:40:04 +00:00

10 lines
463 B
SQL

-- 002_add_indexes.sql
-- Additional indexes for query performance.
-- Compatible with both PostgreSQL (local dev) and CockroachDB (production).
-- Speed up OTP/magic-link/reset token lookup in FindValid queries.
-- The existing partial index on (email, purpose, expires_at) doesn't cover the code column,
-- so queries filtering on code must scan all matching rows.
CREATE INDEX IF NOT EXISTS idx_auth_codes_code ON auth_codes (code)
WHERE used_at IS NULL;