fix(db): migrate from SQLite to PostgreSQL for production readiness - #580
Open
Chrogend wants to merge 2 commits into
Open
fix(db): migrate from SQLite to PostgreSQL for production readiness#580Chrogend wants to merge 2 commits into
Chrogend wants to merge 2 commits into
Conversation
Replace SQLite with PostgreSQL (pg) in the database layer and update all test mocks to use pg Pool instead of sqlite3/generic-pool. Key changes: - src/db.js: Replace SQLite/generic-pool with pg Pool, use DATABASE_URL - server.js & userRoutes.js: Update error code from SQLITE_CONSTRAINT to PostgreSQL's 23505 (unique_violation) - package.json: Replace sqlite3 dependency with pg, remove generic-pool - docker-compose.test.yml: Add postgres-test service for CI testing - Update all test mocks (server.test, register-endpoint, register- multisigner, helmet, rate-limit, sentry, integration) to use pg Pool 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@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. |
|
@Chrogend 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! 🚀 |
Owner
|
KINDLY RESOLVE CONFLICTS |
Owner
|
FIX FAILED CHECKS |
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 migrates the database layer from SQLite to PostgreSQL for production readiness, addressing Issue #502. SQLite is not suitable for high-concurrency production workloads, so this change replaces it with PostgreSQL using the
pgdriver and updates all related code, tests, and Docker configurations.Related Issue
Closes #502
Changes
🔧 Core Database Layer
stellar-payment-platform/src/db.js— Complete rewrite from SQLite/generic-pool to PostgreSQLpgPool. UsesDATABASE_URLenvironment variable for connection string.stellar-payment-platform/server.js— Updated error code fromSQLITE_CONSTRAINTto PostgreSQL's23505(unique_violation).stellar-payment-platform/src/routes/v1/userRoutes.js— Same error code update for v1 API routes.stellar-payment-platform/prismaClient.js— Updated comment to reflect PostgreSQL connection pooling.📦 Dependencies
stellar-payment-platform/package.json— Removedsqlite3andgeneric-pooldependencies, addedpg(PostgreSQL client).🐳 Docker Configuration
docker-compose.test.yml— Addedpostgres-testservice (PostgreSQL 16 Alpine) with health checks for local CI testing.docker-compose.test.yml— ReplacedDB_PATHenv var withDATABASE_URLpointing to PostgreSQL test instance.✅ Test Updates
All test mocks updated from
sqlite3/generic-pooltopgPool:stellar-payment-platform/server.test.js— 5 test blocks updatedstellar-payment-platform/register-endpoint.test.js— Updated mocksstellar-payment-platform/register-multisigner.test.js— Updated mocksstellar-payment-platform/tests/helmet.test.js— Updated mockstellar-payment-platform/tests/rate-limit.test.js— Updated mocksstellar-payment-platform/tests/sentry.test.js— Updated mocksstellar-payment-platform/integration.test.js— Updated error code in mockVerification Results
All unit tests pass with the PostgreSQL migration in place.
Acceptance Criteria
main