A community based topic aggregation platform built on atproto

fix(oauth): Improve migration and test cleanup

- Add goose Up/Down directives to OAuth indexes migration
- Remove WHERE clause from active sessions index (PostgreSQL immutability)
- Clean up unused cookieSecret variable in OAuth test
- Ensure migration rollback works correctly

Changed files
+8 -5
internal
tests
integration
+7 -3
internal/db/migrations/004_add_oauth_indexes.sql
···
+
-- +goose Up
-- Add performance indexes for OAuth tables
-- Migration: 004_add_oauth_indexes.sql
-- Created: 2025-10-06
···
CREATE INDEX IF NOT EXISTS idx_oauth_sessions_did_expires
ON oauth_sessions(did, expires_at);
-
-- Partial index for active sessions (WHERE expires_at > NOW())
+
-- Index for active sessions expiration (removed WHERE clause due to NOW() immutability requirement)
-- This speeds up queries for non-expired sessions
CREATE INDEX IF NOT EXISTS idx_oauth_sessions_active
-
ON oauth_sessions(expires_at)
-
WHERE expires_at > NOW();
+
ON oauth_sessions(expires_at);
-- Index on oauth_requests expiration for faster cleanup
-- (Already exists via migration 003, but documenting here for completeness)
-- CREATE INDEX IF NOT EXISTS idx_oauth_requests_expires ON oauth_requests(expires_at);
+
+
-- +goose Down
+
DROP INDEX IF EXISTS idx_oauth_sessions_active;
+
DROP INDEX IF EXISTS idx_oauth_sessions_did_expires;
+1 -2
tests/integration/oauth_test.go
···
sessionStore := oauthCore.NewPostgresSessionStore(db)
testJWK := `{"alg":"ES256","crv":"P-256","d":"9tCMceYSgyZfO5KYOCm3rWEhXLqq2l4LjP7-PJtJKyk","kid":"oauth-client-key","kty":"EC","use":"sig","x":"EOYWEgZ2d-smTO6jh0f-9B7YSFYdlrvlryjuXTCrOjE","y":"_FR2jBcWNxoJl5cd1eq9sYtAs33No9AVtd42UyyWYi4"}`
-
cookieSecret := "f1132c01b1a625a865c6c455a75ee793572cedb059cebe0c4c1ae4c446598f7d"
tests := []struct {
name string
···
defer os.Unsetenv("OAUTH_PRIVATE_JWK")
// Create handler
-
handler := oauth.NewCallbackHandler(sessionStore, cookieSecret)
+
handler := oauth.NewCallbackHandler(sessionStore)
// Build query string
req := httptest.NewRequest("GET", "/oauth/callback", nil)