in core/src/main/scala/org/apache/pekko/persistence/jdbc/testkit/internal/SchemaUtilsImpl.scala [133:156]
private def applyScriptWithSlick(script: String, separator: String, logger: Logger, database: Database): Done = {
def withStatement(f: Statement => Unit): Done = {
val session = database.createSession()
try session.withStatement()(f)
finally session.close()
Done
}
withStatement { stmt =>
val lines = script.split(separator).map(_.trim)
for {
line <- lines if line.nonEmpty
} yield {
logger.debug(s"applying DDL: $line")
try stmt.executeUpdate(line)
catch {
case t: java.sql.SQLException =>
logger.debug(s"Exception while applying SQL script", t)
}
}
}
}