Created
September 12, 2013 05:58
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
L15の
task
はTask
でしょうか。