In my project I have mariadb and h2 dependencies and data.sql
/schema.sql
.
For development h2 is used, a 'dev' profile is used without spring.datasource.*
properties and a 'prod' profile sets the properties for mariadb.
Before Spring Boot 2.5.0 the behaviour was to use schema.sql
and data.sql
for h2, but not for mariadb.
In Spring Boot 2.5.0 the schema.sql
and data.sql
are executed on each application start/reload.
While this change is surprising there may be good reasons for it, but it should be documented in a prominent manner, as it could lead to problems with production data.
Comment From: philwebb
Thanks for the feedback. This is an unfortunate use-case that we didn't completely consider when we redesigned the code. I've update our release notes to add a warning. Please let me know you think that doesn't cover it.
I'll flag this issue for team attention to see if there's anything else that we can do to try an improve the situation.
Comment From: nfrankel
I think the main issue is moving from a ternary value to a binary one (https://twitter.com/nicolas_frankel/status/1397182454029602822).
You can do less damage by having the default set to false
. The reasoning is that it's better to not initialize the development database than to initialize the production one. You'll spend time investigating the issue in both cases, but in the former, you probably are in less of a hurry than in the latter.
Comment From: philwebb
We're going to try to restore the enum support, although we might not be able to support that with R2DBC
Comment From: everflux
Thanks a lot for taking care and discussing the issue.
Will the detection of embedded or non-embedded database be available again and data/schema.sql only be running with embedded by default?
Comment From: philwebb
@everflux That's our current plan, but we've not dug into the details yet.