fix(db): migrate from SQLite to PostgreSQL for production readiness - #563
Merged
Abdulazeem-code merged 2 commits intoAug 30, 2026
Merged
Conversation
- Replace sqlite3 + generic-pool with pg (node-postgres) in src/db.js - Convert all raw SQL queries from ? placeholders to PostgreSQL syntax - Replace COLLATE NOCASE with ILIKE for PostgreSQL case-insensitive search - Update docker-compose.test.yml to use PostgreSQL instead of SQLite - Replace sqlite3 dependency with pg in package.json - Update all test mocks from sqlite3/generic-pool to pg Pool - Add PostgreSQL-compatible error code handling (P2002 for unique constraints) - Add NODE_ENV=test guard for schema init to prevent process.exit in tests Closes Abdulazeem-code#502
|
@Chrogend is attempting to deploy a commit to the Abdulazeem's projects Team on Vercel. A member of the Team first needs to authorize it. |
Owner
|
KINDLY RESOLVE CONFLICTS |
…-postgresql # Conflicts: # docker-compose.test.yml # stellar-payment-platform/package-lock.json # stellar-payment-platform/package.json # stellar-payment-platform/register-endpoint.test.js # stellar-payment-platform/register-multisigner.test.js # stellar-payment-platform/server.js # stellar-payment-platform/server.test.js # stellar-payment-platform/src/db.js # stellar-payment-platform/src/routes/v1/statsRoutes.js # stellar-payment-platform/src/routes/v1/webhookRoutes.js # stellar-payment-platform/src/webhookWorker.js # stellar-payment-platform/tests/helmet.test.js # stellar-payment-platform/tests/rate-limit.test.js # stellar-payment-platform/tests/sentry.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR completes the migration from SQLite to PostgreSQL for production readiness. The Prisma schema and migrations were already targeting PostgreSQL, but the raw database access layer (
src/db.js) still used SQLite via thesqlite3package withgeneric-pool. This PR replaces the entire SQLite stack withpg(node-postgres) and updates all SQL queries to use PostgreSQL-compatible syntax.Related Issue
Closes #502
Changes
Database Layer
[REWRITE]
src/db.jssqlite3+generic-poolwithpg(node-postgres) PoolCREATE TABLE IF NOT EXISTSwithTIMESTAMPTZNODE_ENV=testguard to preventprocess.exit(1)during test runspoolGet,poolRun,poolAllwith PostgreSQL query interface[MODIFY]
package.jsonsqlite3dependencypg(node-postgres) dependencySQL Query Updates
[MODIFY]
server.js?placeholders to$1PostgreSQL syntaxCOLLATE NOCASEwithILIKEfor case-insensitive searchP2002error code handling for PostgreSQL unique constraint violations[MODIFY]
src/routes/v1/userRoutes.js$1placeholders,ILIKE)[MODIFY]
src/routes/v1/webhookRoutes.js[MODIFY]
src/routes/v1/statsRoutes.js[MODIFY]
src/webhookWorker.jsDocker Compose
docker-compose.test.ymlpostgres-testservice (PostgreSQL 16 Alpine)api-testservice to useDATABASE_URLpointing to PostgreSQL instead ofDB_PATHfor SQLitedepends_onwith health check conditionTests
server.test.js,register-endpoint.test.js,register-multisigner.test.js,helmet.test.js,rate-limit.test.js,sentry.test.js)sqlite3andgeneric-poolmocks withpgPool mocksVerification Results
Acceptance Criteria
Impact