Skip to content

feat(db): index oauth_access_token.session_id for session deletion cascade - #626

Open
ayam04 wants to merge 1 commit into
Noveum:mainfrom
ayam04:fix/594-oauth-session-index
Open

ayam04 wants to merge 1 commit into
Noveum:mainfrom
ayam04:fix/594-oauth-session-index

Conversation

@ayam04

@ayam04 ayam04 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #594.

Adds oauth_access_token_session_idx on session_id — the referencing column of the oauth_access_token.session_id -> session.id FK, which currently has no index. PostgreSQL preserves FK correctness without it, but session deletion may scan the child table as the registry grows.

Changes

  • packages/db/src/schema/oauth.ts: one index added to oauthAccessToken.
  • packages/db/drizzle/0042_right_hannibal_king.sql: append-only migration generated by drizzle-kit (single CREATE INDEX).
  • snapshot + journal entry appended (0042).

Validation

  • Schema change is a single index; the migration is drizzle-kit generated, so the declared schema and the migration agree by construction.
  • Full db:release / db:check-drift / session-deletion exercise require the Postgres harness (Docker), not available in this environment; CI is the oracle for those. No code logic changed, so no unit-test regression is expected.
  • Typecheck baseline on this repo already reports pre-existing dual-drizzle-copy errors unrelated to this change; not chased.

Preserves released 0037/0038 and all prior SQL, snapshots and journal prefixes.

…scade

Adds oauth_access_token_session_idx on session_id, the referencing column
of the oauth_access_token.session_id -> session.id foreign key. PostgreSQL
preserves FK correctness without it, but session deletion may scan the
child table as it grows.

Generated append-only migration 0042 after the current planned sequence;
preserves released 0037/0038 and all prior SQL, snapshots and journal
prefixes. The migration is drizzle-kit generated, so the declared schema
and the migration agree by construction.

Refs Noveum#594

Signed-off-by: ayam04 <[email protected]>
@github-actions

Copy link
Copy Markdown

Thanks for your first pull request to Orbit.

Two things that will save you a review round: bun run verify runs the
same four checks CI does, and the repo has no comments in code by policy,
so bun run check-comments will flag any you added out of habit.

A maintainer will review this shortly. Ask anything on the thread.

@github-actions github-actions Bot added needs tests Touches source without touching a test area: database Schema, migrations, queries, seed area: auth Sign-in, sessions, passkeys, OAuth labels Nov 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: auth Sign-in, sessions, passkeys, OAuth area: database Schema, migrations, queries, seed needs tests Touches source without touching a test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Index OAuth access tokens by session before registry growth

1 participant