Migrate local dev tooling to PostgreSQL and generate all required wallet keys#3838
Merged
Conversation
…let keys The API was migrated to PostgreSQL (#3620) but the local setup tooling still targeted MSSQL. Switch docker-compose, .env.local.example, scripts/setup.js and migration/seed/seed.js to PostgreSQL, and generate every wallet key the blockchain/integration services parse on startup (ICP, Citrea, Ark, KuCoin Pay, payment webhook, Spark, Boltz). Scope the migration-immutability CI check to schema migrations so the seed script can be maintained, and update the README.
Address review feedback: run the sequence setval even when a table is already seeded (so a re-run after an interrupted first seed cannot leave the sequence behind the existing ids), and update scripts/setup.sh to wait on Postgres readiness instead of the removed db-init service.
scripts/setup.sh duplicated the canonical 'npm run setup' flow, was unreferenced, and depended on MSSQL-only seeders (testdata.js, kyc-testdata.js) that are out of scope for this migration and broke under the PostgreSQL switch.
davidleomay
approved these changes
Jun 8, 2026
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.
Summary
The API was migrated to PostgreSQL (#3620), but the local-development tooling still targeted MSSQL, so a fresh
npm run setupcould not produce a working local environment (thepg-based API could not connect to the MSSQL container, and the API crashed on boot because some wallet keys were never generated). This PR aligns the local tooling with the PostgreSQL stack and makes the setup script generate every wallet key the API parses on startup.Changes
Local DB tooling → PostgreSQL
docker-compose.yml: runpostgres:16instead ofmssql/server:2022. Postgres creates the database fromPOSTGRES_DB, so the separatedb-initservice is removed; the healthcheck usespg_isready..env.local.example:SQL_PORT1433 → 5432, andSQL_ENCRYPT→SQL_SSL=false.scripts/setup.js: usepginstead ofmssql. The readiness check, admin-role update and deposit seeding are rewritten as PostgreSQL queries (quoted identifiers,information_schema, parameterized statements). SSL defaults off for this local-only script (opt in viaSQL_SSL=true).migration/seed/seed.js: usepginstead ofmssql. Quote camelCase identifiers, insert real boolean literals, advance the identity sequence after explicit-id inserts, and port the index drop /ip_log/ fiat-fix statements to PostgreSQL.Complete wallet-key generation
npm run setupnow generates every key the blockchain/integration services parse on startup, in the correct format:ICP_WALLET_SEED,PAYMENT_ICP_SEED,BOLTZ_SEED,SPARK_WALLET_SEEDCITREA_WALLET_PRIVATE_KEY,CITREA_WALLET_ADDRESSARK_PRIVATE_KEYDFX_KUCOINPAY_PRIVATE_KEYPAYMENT_WEBHOOK_PRIVATE_KEYPreviously the API crashed on boot because
ICP_WALLET_SEEDandCITREA_WALLET_PRIVATE_KEYwere missing.CI
.github/workflows/api-migration-check.yaml: scope the migration-immutability check to schema migrations only. The seed script and its data undermigration/seed/are actively maintained, not immutable migrations.Docs & cleanup
README.md: update the Docker commands, environment notes and mock-mode section to PostgreSQL.scripts/setup.shbash wrapper: it duplicated the canonicalnpm run setupflow, was not referenced anywhere, and relied on the MSSQL-onlyscripts/testdata.js/scripts/kyc/kyc-testdata.jsseeders (out of this PR's scope).npm run setupis the documented local-setup entrypoint.Acceptance
A fresh
cp .env.local.example .env && docker compose up -d && npm run setupnow:.envedits,ip_log, wallet) plus 5 deposit addresses,http://localhost:3000/swagger(HTTP 200),/v1/realunit/price,/v1/realunit/price/history) instead of 500.Note:
/v1/realunit/accountand/v1/realunit/holdersquery the external Ponder subgraph, which is mocked underENVIRONMENT=loc; those endpoints remain a mock-mode limitation, independent of this change.PR Completeness
docker-compose.yml,.env.local.example.