How to Apply an Existing Evolution Scripts to a Database that will be defined at Runtime?


Any help would. Here is my use-case.

I have an evolution scripts stored at conf/evolutions/templatedb and during runtime, I want to create an instance of play.api.db.Database given a dynamic values that I will get from the user (right now I don’t know how to). And apply the evolution scripts to that Database.
Something like this one.

val url = "jdbc:postgresql://localhost:5432/somedatabase"
val db = Database(url....)
Evolutions.applyEvolutions(db, "templatedb")

I think play.api.db.Databases has what you want.

Already got the answer Greg. Thanks. Btw, here’s what I’ve done.

val username = "..."
val password = "...."
val url = "jdbc:postgresql://localhost:5432/somedatabase"
      url = url,
      driver = "org.postgresql.Driver",
      config = Map(
        "username" ->  username,
        "password" -> password
      name = "templatedb"

Though this requires me to remove slick-evolutions from the build.sbt and add evolutions instead.