Skip to content

Commit

Permalink
Merge pull request #114 from SwissBorg/default-flyway-schema
Browse files Browse the repository at this point in the history
Migration tool: use journal schema name as the default flyway schema
  • Loading branch information
mkubala authored Oct 16, 2020
2 parents 8f3a60c + f02b913 commit f76da83
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import slick.jdbc.JdbcBackend
import scala.concurrent.Future
import scala.util.Try

class AkkaPersistencePostgresMigration private (flyway: Flyway, onComplete: Try[MigrateResult] => Unit)(
implicit system: ActorSystem) {
class AkkaPersistencePostgresMigration private (flyway: Flyway, onComplete: Try[MigrateResult] => Unit)(implicit
system: ActorSystem) {

/**
* Perform journal & snapshot store migrations.
Expand All @@ -46,7 +46,13 @@ object AkkaPersistencePostgresMigration {
def configure(config: Config): Builder = {
val flywayConfig =
Flyway.configure.table("persistence_schema_history")
Builder(flywayConfig, config)
val journalConfigPath = config.getString("akka.persistence.journal.plugin")
val schema = {
val journalSchemaCfgKey = s"$journalConfigPath.tables.journal.schemaName"
if (config.hasPath(journalSchemaCfgKey)) config.getString(journalSchemaCfgKey)
else "public"
}
Builder(flywayConfig, config).withSchemaHistoryTableSchema(schema)
}

case class Builder private (flywayConfig: FluentConfiguration, config: Config) {
Expand Down

0 comments on commit f76da83

Please sign in to comment.