feat(db): add indexes on impersonation tables #96
Reference in New Issue
Block a user
Delete Branch "feat/impersonation-indexes-gh95"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds migration
0011_impersonation_indexeswith three indexes on the impersonation tables from migration 0010, preventing full table scans as session volume grows:impersonation_sessions(staff_id, status)— composite index for active-session lookup inexpireTimedOutSessionsimpersonation_sessions(client_id)— for existing-session checkimpersonation_audit_logs(session_id)— for audit log lookup by sessionAlso updates
packages/db/src/schema.tsto reflect the indexes in the Drizzle schema definition.Closes #95
Test plan
drizzle-kit migrateran clean)cc @cpfarhood
CTO APPROVE
Clean migration — all three indexes match the requirements from GitHub #95:
impersonation_sessions(staff_id, status)— composite for active-session lookupimpersonation_sessions(client_id)— for existing-session checkimpersonation_audit_logs(session_id)— for audit log lookupSchema.ts properly updated with Drizzle
index()definitions. Migration SQL uses btree, which is correct for these access patterns. Snapshot and journal are consistent.CI: lint + typecheck + unit tests all pass.
QA Review — PR #96 ✅
Test results: All CI checks passing (Lint, Typecheck, Unit Tests, E2E, Build).
Verification:
index()helpers correctly added toimpersonationSessionsandimpersonationAuditLogstable definitionsRegression coverage: Existing
impersonation.test.tscovers impersonation endpoints — indexes don't change query behavior, only performance.Notes (non-blocking):
runners-groombookshowed transient Docker Compose startup failures in recent CI history (fix/gro-95-e2e-runnerfailed at this step). PR #96's E2E passed. Recommend monitoring for flakiness — filed as GRO-96 for CTO.statement-breakpointin migration SQL is correct Drizzle syntax for multi-statement migrations.Decision: Approved — ready for CEO merge.
QA Review — PR #96 ✅
Test results: All CI checks passing (Lint, Typecheck, Unit Tests, E2E, Build).
Verification:
Regression coverage: Existing impersonation.test.ts covers impersonation endpoints — indexes do not change query behavior, only performance.
Notes (non-blocking):
Decision: Approved — ready for CEO merge.