diff options
author | vlad <vlad@driver.xyz> | 2017-05-25 17:13:41 -0700 |
---|---|---|
committer | vlad <vlad@driver.xyz> | 2017-05-25 17:13:41 -0700 |
commit | 3dfb989d221d0f121404adaac0d970228fa180a5 (patch) | |
tree | 9f9c765cdcd31178f1ea0d983bb563b0d68c45e8 /src/main/scala/xyz/driver/core/database/database.scala | |
parent | ad33ff15ff642b29e21a82c3e8625feb12567aa7 (diff) | |
parent | 0a3438068e4b853e4c42f83a4eb304ae53382e51 (diff) | |
download | driver-core-3dfb989d221d0f121404adaac0d970228fa180a5.tar.gz driver-core-3dfb989d221d0f121404adaac0d970228fa180a5.tar.bz2 driver-core-3dfb989d221d0f121404adaac0d970228fa180a5.zip |
Merge branch 'master' of https://github.com/drivergroup/driver-core into http-stacktrace
# Conflicts:
# src/main/scala/xyz/driver/core/app.scala
# src/main/scala/xyz/driver/core/rest.scala
Diffstat (limited to 'src/main/scala/xyz/driver/core/database/database.scala')
-rw-r--r-- | src/main/scala/xyz/driver/core/database/database.scala | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/core/database/database.scala b/src/main/scala/xyz/driver/core/database/database.scala index b7a4165..8426309 100644 --- a/src/main/scala/xyz/driver/core/database/database.scala +++ b/src/main/scala/xyz/driver/core/database/database.scala @@ -121,6 +121,23 @@ package database { def naturalKeyMapper[T] = MappedColumnType.base[Id[T], String](_.value, Id[T](_)) } + trait CreateAndDropSchema { + val slickDal: xyz.driver.core.database.SlickDal + val tables: GeneratedTables + + import tables.profile.api._ + import scala.concurrent.Await + import scala.concurrent.duration.Duration + + def createSchema(): Unit = { + Await.result(slickDal.execute(tables.createNamespaceSchema >> tables.schema.create), Duration.Inf) + } + + def dropSchema(): Unit = { + Await.result(slickDal.execute(tables.schema.drop >> tables.dropNamespaceSchema), Duration.Inf) + } + } + trait DatabaseObject extends ColumnTypes { def createTables(): Future[Unit] def disconnect(): Unit |