Skip to main content

Devlog: 2026-03-17 — Local SQL Server Container

What Happened

Added a local SQL Server 2022 container to the Docker Compose dev profile for development and testing. This supersedes the earlier "no local SQL" position from the infrastructure setup.

Why

  • The Azure SQL MI database (PS608 / MWFI Holdings) is read-only -- it's a live client database for reference only
  • Unit and integration tests need a writable database with synthetic test data
  • Local development benefits from sub-millisecond database latency
  • Azure SQL MI charges for compute on all query traffic

What Was Built

FilePurpose
docs-site/docs/adr/adr-018-local-sql-server.mdADR documenting the decision
infra/sql/init/setup.shCustom entrypoint: starts SQL Server, creates PSSaaS_Dev database, runs seed script
infra/sql/init/seed-schema.sqlSchema DDL for core tables needed by BestEx (loan, instruments, counterparties, pricing, profiles, results)
docker-compose.ymlAdded pssaas-db service with health check, updated pssaas-api to depend on db
appsettings.Development.jsonLocal connection string pointing to pssaas-db

Schema Seed

The seed script creates the PSSaaS_Dev database with ~20 core tables matching the SQL MI schema:

  • Reference: pscat_companies, pscat_trade_counterparties, pscat_instruments, pscat_guarantors, pscat_programs, pscat_products, pscat_securitization_rules, pscat_loan_statuses
  • Loan: loan (simplified, 25 key columns out of the full 157)
  • Pricing: pscat_rm_zones, pscat_rm_zone_states, pscat_rm_inv_delivery_win, rmcat_price_adjustment_groups, rmcat_price_adjustments, rmcat_price_adjustment_values, rmcat_profit_margin, rmcat_todays_prices, rmcat_todays_par_rates
  • BestEx: rmcat_bx_profile_names, rmcat_bx_profile_strategies, rmcat_bx_setup_parameters, rmcat_bx_setup_instr_inv, rmcat_bx_setup_lock_windows, rmcat_bestex_analysis, rmcat_bestex_analysis_error

This seed will grow as more modules are implemented. EF Core migrations will eventually replace it.

Technical Notes

  • SQL Server 2022 Linux container is ~700MB (one-time download)
  • The custom entrypoint starts SQL Server in the background, waits for it, then runs the init scripts
  • Health check uses sqlcmd to verify SQL Server is accepting connections before the API starts
  • The API depends on db with condition: service_healthy so it won't start until the database is ready
  • Dev credentials (sa / PSSaaS_Dev_2026!) are acceptable for local dev, never for production

What's Next

  1. Product Owner reviews BestEx spec
  2. Begin BestEx implementation after approval