Skip to content

Instantly share code, notes, and snippets.

@tototoshi
Created September 12, 2013 05:58
Show Gist options
  • Select an option

  • Save tototoshi/6533487 to your computer and use it in GitHub Desktop.

Select an option

Save tototoshi/6533487 to your computer and use it in GitHub Desktop.
The difference of Slick's API between 1.x and 2.0.0-M2
/* 1.0.0 */
import scala.slick.driver.PostgresDriver.simple._
case class Task(id: Int, name: String)
object Task extends Table[Task]("task") {
def id = column[Int]("id")
def name = column[String]("name")
def * = id ~ name <> (Task.apply _, Task.unapply _)
}
val db = Database.forURL("jdbc:postgresql://localhost/example", "user", "password")
db.withSession { implicit session: Session =>
task.ddl.create
}
/* 2.0.0-M2 */
import scala.slick.driver.PostgresDriver.simple._
case class Task(id: Int, name: String)
class TaskTable(tag: Tag) extends Table[Task](tag, "task") {
def id = column[Int]("id")
def name = column[String]("name")
def * = (id, name) <> (Task.tupled, Task.unapply _)
}
val db = Database.forURL("jdbc:postgresql://localhost/example", "user", "password")
val task = TableQuery[TaskTable]
db.withSession { implicit session: Session =>
task.ddl.create
}
@mather
Copy link
Copy Markdown

mather commented Sep 12, 2013

L15の taskTask でしょうか。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment