-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Multiple import.sql files #9464
Comments
I have also considered using persistence.xml, but Quarkus does not allow me to use custom persistence.xml for each profile (and in production setup I can't run the auxiliary script from Quarkus as I am running it with different db role). |
Hi @rvansa , we could add this, I suppose we could accept a list of resource names (comma separated?) to then import them all sequentially. But this would be very similar to you just pasting it all in one script, did you consider that? Also I'm wondering if you shouldn't use one of the Flyway or Liquibase extensions. In general, the Hibernate implementation of |
Have a look at this integration test, it's using both Flyway and ORM, and as you can see setting up the integration is almost zero effort (code would be even simpler if it didn't have to test the migrations): But let me know if I'm missing something and if you still think we should add the support for lists... |
Thanks for the suggestions, @Sanne - as I've mentioned keeping it all in single file is not suitable as some parts are suitable for production and the test data is not. Yes, Flyway or Liquibase could probably do the trick - I was considering using Liquibase before but did not realize that it can be used for the initial setup as well - my bad Flyway is even menioned in https://quarkus.io/guides/hibernate-orm#hibernate-orm-in-development-mode. |
nice, thanks @rvansa . |
So I've been playing with Liquibase a bit and it's nice, however it does not work well in dev setup - Hibernate's drop & create policy. All Liquibase changes are applied before Hibernate kicks in (which makes sense), however as the tables are dropped we lose triggers in the tables (defined by Liquibase). Is it possible to define auxiliary database objects for Hibernate in Quarkus? Since the triggers creation is not that complex I can probably repeat them in Liquibase AND import.sql, though I wonder if there's a better systematic solution. |
Why would you let Hibernate drop the tables if you're using Liquibase? The way I see it, the Hibernate schema tooling is meant for either:
Beyond these contexts, I wouldn't expect you to let Hibernate drop the schema - but please let me know :) |
There's difference between dev and production: In dev, I'd use Liquibase to define the auxiliary objects (tables and triggers that populate these tables based on the primary model). Drop&create is useful (and mandated by some team members) to quickly prototype changes. Once the feature is completed, the developer would check out the model and update Liquibase changelog so that it's in sync in production. |
Ok, thanks! Let's try to implement this then. Do you need this urgently? It's not complex but it requires changes across multiple projects. |
No, it's not urgent at all. Thank you! |
BTW, is there a way to have
That would be a first easy step to be able to execute several SQL files at startup. |
hi @agoncal , no there isn't a way currently. Please open an HHH issue? cc/ @beikov @sebersole might like this and I suppose it wouldn't be too hard. N.B. this would only be possible in the format in which we actually parse the file (which happens to be what is being used in Quarkus) |
The implementation would be pretty simple and I'd suggest we reuse the JPA load script property |
Yeah, I think it will be far less fragile to allow defining several (ordered) files rather than implementing some sort of inclusion in the SQL parser. @beikov I think a comma would be good enough and more in line with what we do in Quarkus. If you don't already have anything like that in ORM, I guess it would be a good choice. |
I think this issue should be closed. I created a PR for this btw: hibernate/hibernate-orm#3999 |
We normally close an issue when it's actually fixed in Quarkus - in this case when an ORM release is made available and when the upgrade PR is merged in Quarkus. |
Hi all, the issue is closed, but I'm trying to include multiple import.sql files and cannot succeed. Also I don't see any mention of this in docs. Shouldn't be as simple as |
Hi @antoniomacri , yes I would have expected that to work as well; it does in Hibernate ORM. I wonder if the Quarkus configuration parsing requires quotes to deal with the ", " separator. Could you try quoting it, or just avoid the space? We should definitely clarify this in the docs! |
Hi Sanne. It doesn't work either:
Gives:
I'm using hibernate-orm-quickstart as base. |
Any news on this? Should I open another issue? |
hi @antoniomacri , yes please open a new issue, I definitely risk losing track of it otherwise :) |
@Sanne Done, thanks! |
Description
Currently
quarkus.hibernate-orm.sql-load-script
accepts only single file. It would be very nice to support a list of files. In my use case I want to keepimport.sql
for test data but at the same time I need to create some extra tables, register triggers etc. in both test and production setup. I don't want to keep these in both production-profile file andimport.sql
, but this needs to be invoked after thedrop-and-create
in dev mode.The text was updated successfully, but these errors were encountered: