Skip to content

feat(backend): migrate to PostgreSQL with connection pooling, indexs and health check#233

Open
JohnOluB wants to merge 10 commits into
StayLitCodes:mainfrom
JohnOluB:feat/postgres-migration-pooling-indexes
Open

feat(backend): migrate to PostgreSQL with connection pooling, indexs and health check#233
JohnOluB wants to merge 10 commits into
StayLitCodes:mainfrom
JohnOluB:feat/postgres-migration-pooling-indexes

Conversation

@JohnOluB
Copy link
Copy Markdown

@JohnOluB JohnOluB commented Apr 23, 2026

PR Description


Backend: PostgreSQL migration with connection pooling and query optimization

Closes #204

What this PR does

Completes the end-to-end migration from SQLite (development) to PostgreSQL (production), fulfilling every acceptance criterion in issue #204.

Files changed
File | Change -- | -- src/data-source.ts | Switched type to postgres, added SlowQueryLogger, pool extra config src/app.module.ts | Switched TypeORM to postgres, pool startup log, imports HealthModule src/migrations/1774364374007-PostgreSQLMigration.ts | New — full PostgreSQL DDL for all 13 entities, all required indexes src/modules/health/health.{controller,service,module}.ts | New — GET /health returning DB connectivity + pool stats .env.example | Added DATABASE_URL, DB_HOST/PORT/USERNAME/PASSWORD/NAME, DB_POOL_* vars docs/POSTGRES_MIGRATION.md | New — step-by-step migration guide for existing deployments
Key technical decisions

SQLite → PostgreSQL DDL changes: Every datetimetimestamptz, boolean DEFAULT (1)/(0)DEFAULT true/false, varchar PRIMARY KEYuuid DEFAULT gen_random_uuid(), all SQLite temporary_* table tricks removed (PostgreSQL supports ALTER TABLE directly).

Connection pooling: Configured via TypeORM's extra key which passes options directly to the underlying pg pool driver — same as pg-pool options. Pool stats are logged on startup and exposed on GET /health.

Slow query logging: A custom SlowQueryLogger class implements TypeORM's Logger interface. It's only activated when NODE_ENV=development via maxQueryExecutionTime: 500.

Indexes added (all required by #204):

  • IDX_users_walletAddress — unique, auth lookups
  • idx_escrows_status, idx_escrows_created_at, idx_escrows_expires_at — dashboard + scheduler
  • IDX_parties_walletAddress — user's escrow lookup
  • IDX_escrow_events_escrowId_createdAt — composite, timeline queries
  • IDX_notification_userId_read — composite, unread count queries

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 23, 2026

@JohnOluB Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@JohnOluB
Copy link
Copy Markdown
Author

JohnOluB commented May 3, 2026

Kindly review pr @Cedarich

@JohnOluB
Copy link
Copy Markdown
Author

JohnOluB commented May 5, 2026

Review Pr @Cedarich

@JohnOluB JohnOluB force-pushed the feat/postgres-migration-pooling-indexes branch from c33ad1f to 2e708c4 Compare May 7, 2026 02:03
@JohnOluB
Copy link
Copy Markdown
Author

JohnOluB commented May 7, 2026

Review pr @Cedarich

@Cedarich
Copy link
Copy Markdown
Contributor

Cedarich commented May 7, 2026

@JohnOluB

@JohnOluB
Copy link
Copy Markdown
Author

JohnOluB commented May 8, 2026

@JohnOluB

Please review @Cedarich

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backend: PostgreSQL migration with connection pooling and query optimization

3 participants