1. Template Flyway config
Take the working config (your flyway-rep.toml or flyway.toml) and turn it into a template.
Example: flyway-template.toml (only the important bits shown)
flyway.url = "jdbc:postgresql://host.docker.internal:5432/@DATABASE@"
flyway.user = "your_user"
flyway.password = "your_password"
flyway.placeholders.domain = "@DOMAIN@"
flyway.placeholders.database = "@DATABASE@"
The @DOMAIN@ and @DATABASE@ strings are just text markers that the batch file will search and replace.
2. migrate-domain-databases.bat
Here’s the rewritten script, formatted cleanly:
@echo off
setlocal enabledelayedexpansion
REM ===== Check argument =====
if "%~1"=="" (
echo Usage: %~nx0 DOMAIN_CODE
echo Example: %~nx0 uopx
exit /b 1
)
set "DOMAIN=%~1"
set "DATABASE=sf_dd_%DOMAIN%_etl_db"
REM ===== 1. Shared ETL DB: use per-domain config file =====
cd /d "%~dp0..\..\infrastructure\flyway\data-domains\etl_db_shared"
REM Make a domain-specific copy of the template config
copy /Y "flyway-template.toml" "flyway-%DOMAIN%.toml" >nul
REM Replace @DOMAIN@ and @DATABASE@ in the copied config
powershell -Command "(Get-Content 'flyway-%DOMAIN%.toml') -replace '@DOMAIN@','%DOMAIN%' -replace '@DATABASE@','%DATABASE%' | Set-Content 'flyway-%DOMAIN%.toml'"
REM Run Flyway with the generated config
flyway "-configFiles=flyway-%DOMAIN%.toml" -environment=local migrate
REM Clean up the temp config
del "flyway-%DOMAIN%.toml"
REM ===== 2. Datastore \ consumption =====
cd "..\%DOMAIN%_datastore\consumption"
flyway migrate -environment=local
REM ===== 3. etl_config =====
cd "..\etl_config"
flyway migrate -environment=local
endlocal
How to use
migrate-domain-databases.bat uopx
migrate-domain-databases.bat pnc
Each run:
Copies flyway-template.toml → flyway-<domain>.toml
Replaces @DOMAIN@ and @DATABASE@ inside the copy
Runs: flyway "-configFiles=flyway-<domain>.toml" -environment=local migrate
Deletes the temp file
Then runs the other flyway migrate -environment=local commands like your original script.
This matches Ralph’s “this works: -configFiles=...” approach but keeps it dynamic per domain, without needing a bunch of hard-coded .toml files.
Thinking
ChatGPT can make mistakes. Check important info.
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)