vendredi 17 janvier 2020

Applying migrations in testcontainers' PostgreSQLContainer

I am currently trying to move our docker-compose based testing setup to a more integrated one using testcontainers.

Since we need to apply around 100 migrations to the database using flyway, I was wondering how I can tell the container to apply those migrations to the postgresSQLContainer? The only configurations I can do on the object are databaseName, username and password.

Where can I configure the migrations or anything else in general?

Currently it looks like this (which is basicly their example):

  class PostgresqlSpec extends FlatSpec with TestContainerForAll {

    override val containerDef: PostgreSQLContainer.Def = PostgreSQLContainer.Def(
      databaseName = "db",
      username = "name",
      password = "password"
    )

    "PostgreSQL container" should "be started" in withContainers { db =>
      assert(db.jdbcUrl.nonEmpty)
    }
  }

I'd appreciate any help or pointers. Btw we are using sbt and play.

Aucun commentaire:

Enregistrer un commentaire