Skip to content

Commit

Permalink
fix initDb
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Sep 13, 2024
1 parent 4c7428d commit e5ad1fc
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/main/g8/src/main/scala/SlickSetup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,26 @@ object SlickSetup {

def initDb(): Unit = {
import scala.concurrent.ExecutionContext.Implicits.global
val result = Seq(
(Breeds.schema ++ Dogs.schema).create,
Breeds.forInsert ++= Seq(
"Collie",
"Terrier"
),
Dogs.forInsert ++= Seq(
("Lassie", 1),
("Toto", 2),
("Wishbone", 2)
)
).map(db.run(_))

Await.result(Future.sequence(result), 5.seconds)
Await.result(
db.run((Breeds.schema ++ Dogs.schema).create),
5.seconds
)

val result = Future.sequence(
Seq(
Breeds.forInsert ++= Seq(
"Collie",
"Terrier"
),
Dogs.forInsert ++= Seq(
("Lassie", 1),
("Toto", 2),
("Wishbone", 2)
)
).map(db.run(_))
)

Await.result(result, 5.seconds)
}
}

0 comments on commit e5ad1fc

Please sign in to comment.