Closed georgleber closed 9 months ago
/cc @geoand (devservices), @stuartwdouglas (devservices)
Quarkus should recognize if there is already data and skip the init-script execution.
I think that's unlikely to happen. Your init-script should be prepared to succeed if the data you're attempting to create already exists (using an IF EXISTS
)
I think that's unlikely to happen. Your init-script should be prepared to succeed if the data you're attempting to create already exists (using an IF EXISTS)
šš¼
Ok, found it a little unintuitive. I was used to spin up e.g. Postgres with initscript, which is run just once initially. So my expectation was, that Quarkus would handle it similarly.
I have changed my script to only import if data does not exist, thanks for the hint. (BTW @gastaldi IF EXISTS does only work for creating structure but unfortunately not for inserting data)
Describe the bug
I have setup my quarkus dev environment using PostgreSQL DB devservice. I have defined
quarkus.datasource.devservices.init-script-path
with an initial SQL script, that is executed correctly. But when definingquarkus.datasource.devservices.volumes
I would expect that the init script is only run once on the first run and after that (volumes exist) it skips initialization.But on the second start, Quarkus fails starting up, because the data that should be setup in the init-script already exists.
Expected behavior
Quarkus should recognize if there is already data and skip the init-script execution.
Actual behavior
On second start Quarkus fials, because the data that should be imported by the init-script already exists.
How to Reproduce?
I have created a small reproducer. After second start, the error shows up. https://github.com/georgleber/quarkus-initscript-volumes-problem
Output of
uname -a
orver
Darwin MBPro 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:55:06 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6020 arm64
Output of
java -version
OpenJDK Temurin-17.0.9
Quarkus version or git rev
3.6.4
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.6