At Spring Boot startup, a Liquibase changelog is executed from this application.properties
:
url=jdbc:postgresql://localhost:5434/comptesfrance
changeLogFile=../AdapterOutboundPostgis/target/classes/db/changelog/compte-france-postgis-changelog.xml
driver=org.postgresql.Driver
username=postgres
password=postgres
port=5434
The connection is done, each changeset is served, except for those of that kind:
<changeSet id="shp2pgsql_communes_2023" author="mlebihan" failOnError="false">
<comment>Importation des shapefiles des contours des communes 2023</comment>
<executeCommand executable="/bin/bash">
<arg value="-c"/>
<arg value="export PGPASSWORD=${password};shp2pgsql -s 4326
-I /data/comptes-france/territoire/2023/communes.shp public.communes_2023 |
psql -d comptesfrance -U postgres -h localhost -p ${port} -q"/>
</executeCommand>
</changeSet>
Here, ${password}
and ${port}
aren't resolved.
/bin/bash -c export PGPASSWORD=${password};shp2pgsql -s 4326
-I /data/comptes-france/territoire/2023/communes.shp public.communes_2023 |
psql -d comptesfrance -U postgres -h localhost -p ${port} -q
I've tried to add a property liquibase.port=5434
in my property file, but without success.
As a workaround I've sat at the top of my changelog:
<property name="port" value="5434" />
<property name="password" value="postgres" />
and then, it works. I can see:
Shell command '/bin/bash -c export PGPASSWORD=postgres;shp2pgsql -s 4326
-I /data/comptes-france/territoire/2023/communes.shp public.communes_2023 |
psql -d comptesfrance -U postgres -h localhost -p 5434 -q' executed
But this cannot stand for long.
Why application.properties
Spring Boot parameters can be interpreted by Liquibase - because it can connect to the database (on a non standard Postgresql port: 5434
) - and not be found for the changelogs/changesets at the same time?
Spring boot defines Liquibase (LB) properties under it's own perfix spring.liquibase
. If you'd like to pass parameters to the LB you should have something like this:
spring.liquibase.parameters.port=5434
spring.liquibase.parameters.password=postgres