-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support import.sql or similar facility for data population when not using Hibernate to create the schema #21866
Comments
Good idea! |
We keep getting similar bug reports (latest: #23821) from users who are suprised that Anyway, I'm getting more and more convinced that the problem is, beyond the missing feature, that our configuration is confusing. And the problem is made worse by the fact that configuration properties involved in schema generation don't even have "schema" in their name. For example At the very least, I think we should get rid of If I dared, I would suggest to go further and:
While I believe it's for the best, I suspect this won't be a popular change given that most Quarkus applications out there probably use |
Is there any progress on this issue ? I'd really like to have an option to use And may I ask what the reason is for not supporting the Testcontainer's jdbc url ? |
Not yet. Personally this didn't make it to the top of my todo-list. I don't know about other contributors.
I'm not sure what you're referring to. We didn't talk about a JDBC URL at all in this ticket? If this question is unrelated to this ticket, please ask it on a relevant ticket and/or start a Discussion. |
The Quarkus Guide Dev Services for Databases says that Quarkus is not using the Testcontainer's jdbc driver, so therefore we can't pass extra arguments to the connection url of Testcontainers, like mentioned here in the documentation. If this would have been possible, then this issue would not exist. Currently, I don't see any other option then injecting the It would have been nice, like the OP mentioned, to have the option to configure it:
In my case, I'm working with Debezium Embedded, and I need to connect to two databases that I want to startup via dev-services and they need to have tables and some initial data before the tests start. |
Can be #30455 treated as sufficient solution for this issue? (So it can be closed) |
Unfortunately it cannot. This issue is not limited to dev services. From the initial description:
Also, some people want this feature in production (e.g. #23821). |
OK, thanks Yoann. |
I've been reading this and the other related issues and I'm unable to understand which work arounds are being used? I want to use flyway to manage the schema creation, but the tests and local dev I want to be able have an import.sql file to insert to some data.
I understand that this might not be a priority but in case someone find a good approach to this please let me know. Thank you |
That's the only viable workaround ATM in my opinion. Something like this could work, and not even be that bad, assuming you put your test migration scripts in
You may have to adjust the filesystem path to match the current working directory (I assumed it's just the project's directory). If you run integration tests, this won't work though, because
|
Ok, I think I made it work with an extra dir called Some more examples here: https://github.com/quarkusio/quarkus/blob/main/integration-tests/flyway/src/main/resources/application.properties Thank you |
Related development in Hibernate ORM itself: https://hibernate.atlassian.net/browse/HHH-19103 |
Description
If I am using JPA to create my schema through Hibernate, I can easily add test data by creating an
import.sql
file in my resources.However if I switch to using Flyway with PostgreSQL dev services, there doesn't seem to be an easy to do this except creating some extra migrations which are just used for test.
In Spring Boot I can create a
data.sql
file in my resources, and I can configure Spring Boot to execute this regardless of how my schema was created or what database I am using.I am aware of the
TC_INITSCRIPT
option for test containers - but this would not work for our CI builds on k8s where TestContainers is not used (and in addition there doesn't seem to be an easy way to configure this when using dev services -quarkus.datasource.devservices.properties.TC_INIT_SCRIPT
is documented not to work).Implementation ideas
No response
The text was updated successfully, but these errors were encountered: