class User(tag: Tag) extends Table[(Int, String, String, String)](tag, "USERS") { def id = column[Int]("USER_ID", O.PrimaryKey) //...}def users(tenantSchema: Option[String]) = new TableQuery(new User(_, tenantSchema, "USERS"))
class User(tag: Tag, tenantSchema: Option[String]) extends Table[(Int, String, String, String)](tag, tenantSchema, "USERS") { def id = column[Int]("USER_ID", O.PrimaryKey) //...}def users(tenantSchema: Option[String]) = new TableQuery(new User(_, tenantSchema))
class Invoice(tag: Tag, tenantSchema: Option[String]) extends Table[(Int, String, String, Double)](tag, tenantSchema, "INVOICES") { def issuerID = column[Int]("ISSUER_ID") //... def issuedBy = foreignKey("ISSUER_FK", issuerID, users(tenantSchema))(_.id, onUpdate=ForeignKeyAction.Restrict, onDelete=ForeignKeyAction.Cascade) }
I don't see why not, but I think it's safer to make the schema a parameter or property of the enclosing class/method.
--
---
You received this message because you are subscribed to the Google Groups "Slick / ScalaQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalaquery+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalaquery/3a3b891e-d83e-4736-8429-7fc25a3abe29%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sorry ... because that way within the scope you know you're using the same schema, and from the outside, instead of threading the schema through lots of calls you just need to hold onto the schema "DAO."