Migrate database from MS SQL to PostgreSQL#164
Merged
davidleomay merged 3 commits intodevelopfrom Apr 17, 2026
Merged
Conversation
Switch TypeORM driver from mssql to postgres, convert all entity column types (datetime2→timestamp, float→double precision, nvarchar→text/varchar), rewrite 18 migration files from T-SQL to PostgreSQL syntax, update raw SQL queries (FORMAT→TO_CHAR), replace MssqlDebugConfig with PostgresDebugConfig, and swap docker-compose from MS SQL Server to PostgreSQL 17.
f3dd06d to
d0ded02
Compare
- Fix ALTER COLUMN syntax in setupFrankencoinPay migration (DROP/SET NOT NULL) - Convert SELECT TOP N to LIMIT N in db-debug.sh script - Add pg_temp to blocked schemas in debug config - Add missing dangerous functions (dblink_exec, dblink_connect, pg_sleep, pg_execute_server_program)
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
mssqltopostgresin configdatetime2→timestamp,float→double precision,nvarchar(MAX)→textIDENTITY→SERIAL,getdate()→CURRENT_TIMESTAMP,sp_rename→ALTER TABLE RENAME, etc.)FORMAT()→TO_CHAR()MssqlDebugConfigwithPostgresDebugConfig(blocked schemas, dangerous functions)docker-compose.ymlfrom MS SQL Server 2022 to PostgreSQL 17.env.example(port 5432, username postgres)mssqlnpm package (pgwas already present)Context
Part of the LDS migration (Stufe 1): MS SQL → PostgreSQL on Azure, before infrastructure move to DFX servers. See
DFXServer/server→infrastructure/migrations/lds-migration.md.Dieser PR enthält nur den Code-Umbau. Die API verbindet sich nach dem Deploy mit PostgreSQL — die Datenbank auf Azure ist aber noch MS SQL. Ohne Infrastruktur-Vorbereitung crasht die API.
Voraussetzungen vor dem Merge:
app-lds-api-devtesten, bevor PRD umgestellt wirdCutover-Ablauf (ca. 10 min Downtime):
SQL_HOST,SQL_PORT,SQL_USERNAME,SQL_PASSWORD) auf PostgreSQL umstellenRollback:
Env-Vars zurück auf MS SQL, alten Code deployen (revert commit), API starten.
Test plan
docker compose up -d→ lokaler PostgreSQL startetSQL_SYNCHRONIZE=true→ Schema korrekt erstellt