Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package models.database
- import play.api.db.slick.Config.driver.simple._
- import com.github.tototoshi.slick.H2JodaSupport._
- import models.{ClientTag, Client}
- import org.joda.time.DateTime
- import scala.slick.model.ForeignKeyAction
- /**
- * Created by ed on 4/15/14.
- */
- class Clients(tag: Tag) extends Table[Client](tag, "clients") {
- def id = column[Long] ("id", O.PrimaryKey, O.AutoInc)
- def host = column[String] ("host")
- def accessKey = column[String] ("access_key")
- def createdOn = column[DateTime] ("created_on")
- def expiresOn = column[DateTime] ("expires_on")
- def * = (id.?, host, accessKey, createdOn, expiresOn) <> (Client.tupled, Client.unapply _)
- def hostIdx = index("clients_idx_host", host)
- }
- class ClientTags(tag: Tag) extends Table[ClientTag](tag, "client_tags") {
- def clientId = column[Long] ("client_id")
- def tagName = column[String] ("tag_name")
- def client = foreignKey("fk_clients", clientId, DAO.clients)(_.id, onDelete = ForeignKeyAction.Cascade)
- def * = (clientId, tagName) <> (ClientTag.tupled, ClientTag.unapply _)
- }
- object DAO {
- lazy val clients = TableQuery[Clients]
- lazy val clientTags = TableQuery[ClientTags]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement