I use slick2+postgresql 9.3+playframework 2
My data model is:
class Page(tag:Tag) extends Table[(Long,Long, String,String,String, Option[Long], Option[Long])](tag, "Page"){
def id=column[Long]("ID", O.PrimaryKey)
def subId=column[Long]("subject")
def title=column[String]("Title", O.NotNull)
def describe=column[String]("Describe")
def profile=column[String]("Profile")
def icon=column[Long]("icon")
def resId=column[Long]("Picture")
def * = (id, subId,title, describe, profile,icon.?, resId.?)
def page_sub=foreignKey("PA_SU_FK", subId, subject)(_.id)
def page_res=foreignKey("PA_RE_FK", resId, resource)(_.id)
}
the problem is the column describe is String and will be mapping as varchar(254) in database. But actually, this column may very very long, I mean it may 1000-3000 characters. how to manually mapping it to text in Datamodel?
This should work for PostgreSQL
:
def profile=column[String]("Profile", O.DBType("TEXT"))
Or you could build a custom TypeMapper
, I never built one but there are a lot of posts around, like this SO question or this question.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With