I am using slick 2.x codegen to generate Scala models from a database schema. However, is it possible to overcome the limitations of a foreign key to create related models, for example. if i have this circuit
CREATE TABLE people(id INT PRIMARY KEY AUTO INCREMENT, name VARCHAR(31));
CREATE TABLE dogs(name VARCHAR(31), ownerId INT FOREIGN KEY people(id));
I get the following models from slick:
case class PeopleRow(id: Int, name: String)
case class DogsRow(name: String, ownerId: Int)
But I really want:
case class PeopleRow(id: Int, name: String)
case class DogsRow(name: String, owner: PeopleRow)
or even better:
case class PeopleRow(id: Int, name: String) {
def dogs: List[DogsRow]
}
case class DogsRow(name: String, ownerId: People) {
lazy val owner: People
}
Do I need to override slick codegen for this?
source
share