Using gradle, I do have the following pipeline:
- liquibase runs against local postgres to apply SQL-based changes
- JOOQ generator invoked right after it and generates the enteties
- another round of liquibase is started, but this time contains only code-based (aka customChange) migrations
On step 3 it is always failing with
Caused by: liquibase.exception.DatabaseException: Error executing SQL SHOW SEARCH_PATH: This connection has been closed.
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:89)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:201)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:209)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:217)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:232)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:227)
at liquibase.database.core.DatabaseUtils.initializeDatabase(DatabaseUtils.java:41)
at liquibase.database.core.PostgresDatabase.rollback(PostgresDatabase.java:403)
at liquibase.lockservice.StandardLockService.releaseLock(StandardLockService.java:361)
The customChange looks pretty standard:
class Migration1 : CustomTaskChange {
private lateinit var resourceAccessor: ResourceAccessor
override fun getConfirmationMessage(): String = "Migration ${this.javaClass.name} completed successfully."
override fun setUp() {
// noop
}
override fun setFileOpener(resourceAccessor: ResourceAccessor) {
this.resourceAccessor = resourceAccessor
}
override fun validate(database: Database): ValidationErrors = ValidationErrors()
override fun execute(database: Database) {
try {
val connection = database.connection as JdbcConnection
connection.use {
it.wrappedConnection.use { psql ->
DSL.using(psql).execute()
}
}
} catch (e: Exception) {
throw CustomChangeException(e)
}
}
}
I also tried the basic example of
override fun execute(database: Database) {
try {
val connection = database.connection as JdbcConnection
val test = connection.createStatement().executeQuery("select * from workflow")
test.next()
} catch (e: Exception) {
throw CustomChangeException(e)
}
}
which is also fails with the same error.
Any idea? Thank you in advance