Skip to content

Commit

Permalink
kan spesifisere WAL level
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsteinsland committed Nov 6, 2024
1 parent c0fd9f5 commit f3e97fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ class DatabaseContainer(
private val appnavn: String,
private val poolSize: Int,
private val cleanUpTables: CleanupStrategy? = null,
private val maxHikariPoolSize: Int = 2
private val maxHikariPoolSize: Int = 2,
private val walLevelLogical: Boolean = false
) {
private val instance by lazy {
PostgreSQLContainer<Nothing>("postgres:15").apply {
withCreateContainerCmdModifier { command -> command.withName(appnavn) }
if (walLevelLogical) {
// Cloud SQL har wal_level = 'logical' på grunn av flagget cloudsql.logical_decoding i
// naiserator.yaml. Vi må sette det samme lokalt for at flyway migrering skal fungere.
withCommand("postgres", "-c", "wal_level=logical")
}
withReuse(true)
withLabel("app-navn", appnavn)
DockerClientFactory.lazyClient().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ object DatabaseContainers {

// gjenbruker containers med samme navn for å unngå
// å spinne opp mange containers
fun container(appnavn: String, cleanUpTables: CleanupStrategy? = null, maxHikariPoolSize: Int = 2, databasePoolSize: Int = POOL_SIZE): DatabaseContainer {
fun container(appnavn: String, cleanUpTables: CleanupStrategy? = null, maxHikariPoolSize: Int = 2, databasePoolSize: Int = POOL_SIZE, walLevelLogical: Boolean = false): DatabaseContainer {
return instances.getOrPut(appnavn) {
DatabaseContainer(appnavn, databasePoolSize, cleanUpTables, maxHikariPoolSize)
DatabaseContainer(appnavn, databasePoolSize, cleanUpTables, maxHikariPoolSize, walLevelLogical)
}
}
}

0 comments on commit f3e97fa

Please sign in to comment.