KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How do I tell Slick to create a Decimal SQL type which allows for decimals? It seems that by default Slick doesn't allows for decimals which I noticed with the below code. It creates a column with the data type decimal(10,0) in MySQL. I have the following model in my Scala code: import scala.slick.driver.MySQLDriver.simple._ case class TimeType(id: Option[Int], name: String, employeeMultiplier: BigDecimal, employerMultiplier: BigDecimal) object TimeTypes extends Table[TimeType]("timeType") { def id = column[Int]("id", O.PrimaryKey, O.AutoInc) def name = column[String]("name") def employeeMultiplier = column[BigDecimal]("employeeMultiplier") def employerMultiplier = column[BigDecimal]("employerMultiplier") def * = id.? ~ name ~ employeeMultiplier ~ employerMultiplier <> (TimeType, TimeType.unapply _) } During startup I create this table using Slick unless it already exists with this code ... lazy val database = Database.forDataSource(DB.getDataSource()) database.withSession { if (MTable.getTables("timeType").list.isEmpty) { TimeTypes.ddl.create ...
Tags (comma-separated)
Save Edits
Cancel