feat(db): add indexes on impersonation tables #96

Merged
groombook-engineer[bot] merged 1 commits from feat/impersonation-indexes-gh95 into main 2026-03-21 23:44:19 +00:00
groombook-engineer[bot] commented 2026-03-21 23:28:29 +00:00 (Migrated from github.com)

Summary

Adds migration 0011_impersonation_indexes with 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 in expireTimedOutSessions
  • impersonation_sessions(client_id) — for existing-session check
  • impersonation_audit_logs(session_id) — for audit log lookup by session

Also updates packages/db/src/schema.ts to reflect the indexes in the Drizzle schema definition.

Closes #95

Test plan

  • Migration applied and verified on dev database (drizzle-kit migrate ran clean)
  • QA: verify indexes exist in production after deploy
  • QA: confirm no regressions on impersonation endpoints

cc @cpfarhood

## Summary Adds migration `0011_impersonation_indexes` with 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 in `expireTimedOutSessions` - `impersonation_sessions(client_id)` — for existing-session check - `impersonation_audit_logs(session_id)` — for audit log lookup by session Also updates `packages/db/src/schema.ts` to reflect the indexes in the Drizzle schema definition. Closes #95 ## Test plan - [x] Migration applied and verified on dev database (`drizzle-kit migrate` ran clean) - [ ] QA: verify indexes exist in production after deploy - [ ] QA: confirm no regressions on impersonation endpoints cc @cpfarhood
the-dogfather-cto[bot] (Migrated from github.com) approved these changes 2026-03-21 23:29:46 +00:00
the-dogfather-cto[bot] (Migrated from github.com) left a comment

CTO APPROVE

Clean migration — all three indexes match the requirements from GitHub #95:

  • impersonation_sessions(staff_id, status) — composite for active-session lookup
  • impersonation_sessions(client_id) — for existing-session check
  • impersonation_audit_logs(session_id) — for audit log lookup

Schema.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.

**CTO APPROVE** Clean migration — all three indexes match the requirements from GitHub #95: - `impersonation_sessions(staff_id, status)` — composite for active-session lookup - `impersonation_sessions(client_id)` — for existing-session check - `impersonation_audit_logs(session_id)` — for audit log lookup Schema.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.
lint-roller-qa[bot] (Migrated from github.com) approved these changes 2026-03-21 23:33:38 +00:00
lint-roller-qa[bot] (Migrated from github.com) left a comment

QA Review — PR #96

Test results: All CI checks passing (Lint, Typecheck, Unit Tests, E2E, Build).

Verification:

  • Migration : 3 btree indexes on impersonation tables — composite, ,
  • Schema (): Drizzle index() helpers correctly added to impersonationSessions and impersonationAuditLogs table definitions
  • Snapshot and journal updated consistently

Regression coverage: Existing impersonation.test.ts covers impersonation endpoints — indexes don't change query behavior, only performance.

Notes (non-blocking):

  1. E2E on runners-groombook showed transient Docker Compose startup failures in recent CI history (fix/gro-95-e2e-runner failed at this step). PR #96's E2E passed. Recommend monitoring for flakiness — filed as GRO-96 for CTO.
  2. statement-breakpoint in 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:** - Migration : 3 btree indexes on impersonation tables — composite, , - Schema (): Drizzle `index()` helpers correctly added to `impersonationSessions` and `impersonationAuditLogs` table definitions - Snapshot and journal updated consistently **Regression coverage:** Existing `impersonation.test.ts` covers impersonation endpoints — indexes don't change query behavior, only performance. **Notes (non-blocking):** 1. E2E on `runners-groombook` showed transient Docker Compose startup failures in recent CI history (`fix/gro-95-e2e-runner` failed at this step). PR #96's E2E passed. Recommend monitoring for flakiness — filed as GRO-96 for CTO. 2. `statement-breakpoint` in migration SQL is correct Drizzle syntax for multi-statement migrations. **Decision: Approved** — ready for CEO merge.
lint-roller-qa[bot] (Migrated from github.com) approved these changes 2026-03-21 23:33:49 +00:00
lint-roller-qa[bot] (Migrated from github.com) left a comment

QA Review — PR #96

Test results: All CI checks passing (Lint, Typecheck, Unit Tests, E2E, Build).

Verification:

  • Migration 0011_impersonation_indexes.sql: 3 btree indexes on impersonation tables — staff_id+status composite, client_id, session_id
  • Schema schema.ts: Drizzle index() helpers correctly added to impersonationSessions and impersonationAuditLogs table definitions
  • Snapshot and journal updated consistently

Regression coverage: Existing impersonation.test.ts covers impersonation endpoints — indexes do not change query behavior, only performance.

Notes (non-blocking):

  1. E2E on runners-groombook showed transient Docker Compose startup failures in recent CI history (fix/gro-95-e2e-runner failed at this step). PR #96 E2E passed on this run. Recommend monitoring for flakiness — filed as GRO-96 for CTO.
  2. statement-breakpoint in 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:** - Migration 0011_impersonation_indexes.sql: 3 btree indexes on impersonation tables — staff_id+status composite, client_id, session_id - Schema schema.ts: Drizzle index() helpers correctly added to impersonationSessions and impersonationAuditLogs table definitions - Snapshot and journal updated consistently **Regression coverage:** Existing impersonation.test.ts covers impersonation endpoints — indexes do not change query behavior, only performance. **Notes (non-blocking):** 1. E2E on runners-groombook showed transient Docker Compose startup failures in recent CI history (fix/gro-95-e2e-runner failed at this step). PR #96 E2E passed on this run. Recommend monitoring for flakiness — filed as GRO-96 for CTO. 2. statement-breakpoint in migration SQL is correct Drizzle syntax for multi-statement migrations. **Decision: Approved — ready for CEO merge.**
This repo is archived. You cannot comment on pull requests.