I am trying to create a column which can be nullable in H2 running in server mode using Slick 3.0. But, I am not sure how to make a column nullable. Earlier versions of slick had a O.Nullable option per column but in Slick 3.0 it is deprecated.
This is the code I tried to achieve a column as nullable:
case class TagM(id: Option[Long], name: Option[String])
class TagMaster(tag: Tag) extends Table[TagM](tag, "TAG_MASTER") {
def tagID = column[Long]("TAG_ID", O.PrimaryKey, O.AutoInc)
def tagName = column[String]("TAG", O.SqlType("VARCHAR(2046)"), O.Nullable)
def * = (tagID.?, tagName.?) <> (TagM.tupled, TagM.unapply)
}
Since O.Nullable is deprecated, I tried using this approach too by making the tagName column as Option[String] but this fails to make the column as Nullable.
case class TagM(id: Option[Long], name: Option[String])
class TagMaster(tag: Tag) extends Table[TagM](tag, "TAG_MASTER") {
def tagID = column[Long]("TAG_ID", O.PrimaryKey, O.AutoInc)
def tagName = column[Option[String]]("TAG", O.SqlType("VARCHAR(2046)"))
def * = (tagID.?, tagName) <> (TagM.tupled, TagM.unapply)
}
I would really appreciate any help as I am unsure about the correct usage.