quarkiverse / quarkus-mybatis

Quarkus MyBatis Extension
Apache License 2.0
86 stars 33 forks source link

Support multiple files in quarkus.mybatis.initial-sql #341

Open p91paul opened 11 months ago

p91paul commented 11 months ago

It can be useful to be able to specify multiple initial sql files, expecially if one or more of them is generated. Currently initial-sql seems to support a single file (https://github.com/quarkiverse/quarkus-mybatis/blob/a3b6fa47df80d1dc684633dc1c97175e4f5d2a5c/mybatis/runtime/src/main/java/io/quarkiverse/mybatis/runtime/MyBatisRecorder.java#L428), can it be enhanced to be able to specify many files?

To cite similar implementations in other frameworks, Spring supports this behavior through the spring.sql.init.schema-locations configuration; multiple files can be specified with a comma separator, like this:

spring:
  datasource:
    url: jdbc:h2:mem:test
    username: sa
    password: sa
  sql:
    init:
      schema-locations: classpath*:test-data/schema-h2.sql,classpath*:test-data/tables-h2.sql,classpath*:test-data/alias-h2.sql
zhfeng commented 11 months ago

Thanks @p91paul and yeah, I think we can improve to support multiple files. Are you interesting to contribute?

p91paul commented 11 months ago

Sorry, I made that suggestion because I think it's a nice addition, but I'm currently unable to sponsor this with my time or otherwise. Of course that means I won't expect any kind of timeline for implementation.

I'm currently working around this by using the INIT parameter in h2 connection string (because that's my specific use case for this feature).

Thanks for your work on this quarkus extension!