I have my tables schema generated from the database, I'm trying to execute the ddl to create the tables using an r2dbc connection to an h2 in memory, but I cannot figure out what should I do.
The DSLContext.ddl
method returns a Queries
object that is not a Publisher
and I cannot find any way to execute those queries with a Publisher
but only doing a .block()
method that is failing because r2dbc doesn't allow for blocking calls.
Any help?
It seems DDL with R2DBC have weird issues in JOOQ, the only way I found to make it work across different databases (MySQL, H2) is, execute the raw SQL of the DDL manually with:
public static void initDB(ConnectionFactory connectionFactory) {
var dsl = DSL.using(connectionFactory);
Mono.from(connectionFactory.create())
.flatMapMany(conn -> Flux.fromIterable(dsl.ddl(MySchema.MY_SCHEMA))
.flatMap(query -> conn.createStatement(query.getSQL()).execute(), 1)
)
.blockLast();
}