Skip to content

Commit

Permalink
fix: remove db migration clash
Browse files Browse the repository at this point in the history
  • Loading branch information
rlemaitre committed Mar 13, 2024
1 parent 5800e98 commit c0272e3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ lazy val docs = Project("pillars-docs", file("modules/docs"))

lazy val pillars = project
.in(file("."))
.aggregate(core, example, docs, db, flags, httpClient)
.aggregate(core, example, docs, db, dbDoobie, dbMigrations, flags, httpClient)
.settings(
name := "pillars",
publishArtifact := false,
Expand Down
2 changes: 1 addition & 1 deletion docToolchainConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ microsite.with {
// set a title to '-' in order to remove this menu entry.
menu = ['user-guide': 'User Guide', 'contribute': 'Contribute', 'features': 'Features']

version = '0.1.0'
version = '0.1.1'

//tag::additionalConverters[]
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ import munit.CatsEffectSuite
import org.testcontainers.utility.DockerImageName
import org.typelevel.otel4s.trace.Tracer
import pillars.Config.Secret
import pillars.Module
import pillars.Pillars
import pillars.db.*
import pillars.db.migrations.{DBMigration, MigrationConfig}
import pillars.db.migrations.DBMigration
import pillars.db.migrations.MigrationConfig
import pillars.probes.ProbeConfig
import pillars.{Module, Pillars}
import scala.concurrent.duration.*
import skunk.*
import skunk.codec.all.*
import skunk.implicits.*

import scala.concurrent.duration.*

class MigrationTests extends CatsEffectSuite, TestContainerForEach:

override val containerDef: PostgreSQLContainer.Def = PostgreSQLContainer.Def(
Expand Down Expand Up @@ -58,11 +59,11 @@ class MigrationTests extends CatsEffectSuite, TestContainerForEach:
)
val dbConfig: DatabaseConfig = configFor(pgContainer)
val migration = DBMigration[IO](config, dbConfig)
val result =
val result =
for
_ <- migration.migrate("db/migrations")
_ <- migration.migrate("db/migrations")
res <- session(dbConfig).use: s =>
s.unique(sql"SELECT count(*) FROM test where d is not null".query(int8))
s.unique(sql"SELECT count(*) FROM test where d is not null".query(int8))
yield res
assertIO(result, 5L)
}
Expand All @@ -75,11 +76,11 @@ class MigrationTests extends CatsEffectSuite, TestContainerForEach:
)
val dbConfig: DatabaseConfig = configFor(pgContainer)
val migration = DBMigration[IO](config, dbConfig)
val result =
val result =
for
_ <- migration.migrate("db/migrations", DatabaseSchema.public, DatabaseTable("schema_history"))
_ <- migration.migrate("db/migrations", DatabaseSchema.public, DatabaseTable("schema_history"))
res <- session(dbConfig).use: s =>
s.unique(sql"SELECT count(*) FROM schema_history".query(int8))
s.unique(sql"SELECT count(*) FROM schema_history".query(int8))
yield res
assertIO(result, 3L) // 1 for init and one for each migration file
}
Expand All @@ -92,12 +93,12 @@ class MigrationTests extends CatsEffectSuite, TestContainerForEach:
)
val dbConfig: DatabaseConfig = configFor(pgContainer)
val migration = DBMigration[IO](config, dbConfig)
val result =
val result =
for
_ <- migration.migrate("db/migrations")
_ <- migration.migrate("db/migrations")
_ <- migration.migrate("db/migrations")
_ <- migration.migrate("db/migrations")
res <- session(dbConfig).use: s =>
s.unique(sql"SELECT count(*) FROM test where d is not null".query(int8))
s.unique(sql"SELECT count(*) FROM test where d is not null".query(int8))
yield res
assertIO(result, 5L)
}
Expand Down
2 changes: 1 addition & 1 deletion modules/example/src/main/scala/example/app.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object app extends pillars.EntryPoint: // // <1>
def run: Run[IO, IO[Unit]] = // // <4>
for
_ <- Logger[IO].info(s"📚 Welcome to ${Config[IO].name}!")
_ <- DBMigration[IO].migrate("db/migrations") // // <5>
_ <- DBMigration[IO].migrate("db-migrations") // // <5>
_ <- flag"feature-1".whenEnabled:
DB[IO].use: session =>
for
Expand Down

0 comments on commit c0272e3

Please sign in to comment.