Basic database structure and partial implementation for UACs and tokens
This commit is contained in:
parent
9c6a1e808f
commit
36afeaad42
13 changed files with 454 additions and 192 deletions
41
src/main/scala/db/DatabaseLayer.scala
Normal file
41
src/main/scala/db/DatabaseLayer.scala
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package db
|
||||
|
||||
import modules.uac.UACModule
|
||||
import modules.executor.ExecutorModule
|
||||
|
||||
import scala.concurrent.Future
|
||||
import slick.jdbc.JdbcProfile
|
||||
import scala.concurrent.ExecutionContext
|
||||
|
||||
class DatabaseLayer(
|
||||
val uac: UACModule,
|
||||
val exec: ExecutorModule
|
||||
)
|
||||
|
||||
|
||||
object DatabaseLayer:
|
||||
def setup(
|
||||
profile: JdbcProfile,
|
||||
config_loc: String = "db_conf"
|
||||
)(implicit ec: ExecutionContext): Future[DatabaseLayer] =
|
||||
import profile.api._
|
||||
val database = Database.forConfig(config_loc)
|
||||
|
||||
// Construct and initialize modules
|
||||
val uacModule = UACModule(profile, database)
|
||||
val uacSetupActions = uacModule.setup
|
||||
|
||||
val executorModule = ExecutorModule(profile, database)
|
||||
val executorSetupOptions = executorModule.setup
|
||||
|
||||
// Run initialization actions
|
||||
val initActions = DBIO.seq(
|
||||
uacSetupActions,
|
||||
executorSetupOptions
|
||||
)
|
||||
|
||||
database.run(initActions).map(_ =>
|
||||
DatabaseLayer(uacModule, executorModule)
|
||||
)
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue