All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.malliina.database.Conf.scala Maven / Gradle / Ivy

There is a newer version: 6.9.4
Show newest version
package com.malliina.database

import com.malliina.config.ConfigReadable

case class Conf(
  url: String,
  user: String,
  pass: String,
  driver: String,
  maxPoolSize: Int,
  autoMigrate: Boolean,
  schemaTable: String = Conf.DefaultSchemaTable
)

object Conf:
  val MySQLDriver = "com.mysql.cj.jdbc.Driver"
  val DefaultSchemaTable = "flyway_schema_history"

  given ConfigReadable[Conf] = ConfigReadable.node.emap: c =>
    for
      url <- c.parse[String]("url")
      user <- c.parse[String]("user")
      pass <- c.parse[String]("pass")
      driver <- c.parse[String]("driver")
      maxPoolSize <- c.parse[Int]("maxPoolSize")
      autoMigrate <- c.parse[Boolean]("autoMigrate")
      schemaTable <- c.opt[String]("schemaTable")
    yield Conf(
      url,
      user,
      pass,
      driver,
      maxPoolSize,
      autoMigrate,
      schemaTable.getOrElse(DefaultSchemaTable)
    )




© 2015 - 2024 Weber Informatics LLC | Privacy Policy