For a multi tenant application I need to create I want to evaluate how convenient is Slick for creating queries against Postgres different schemas (not to confuse with schema tables).
I'm having a hard time finding how to configure TableQuery to use dynamically the schema provided by the user. TableQuery[Users].resul should return different datasets depending on me querying tenant A or tenant B.
Is it possible with current Slick versions?
TableQueryitself will not need to be configured, as its methods only return queries and actions. Actions are run by aDatabaseDefinstance, and that is what will need to be configured to access different schemas/databases/etc. Slick official documentation describes a simple way to create an instance of aDatabaseDef, which by default uses the Typesage Config library:where
"mydb"specifies a key in a property file Typesafe Config is looking at. You can create and manipulateConfiginstances programmatically as well, and createdbinstances from those. I suspect you will have to do something along the lines of creating a newConfiginstance (there is the convenientwithValue()method to copy aConfigand replace a config value at the specified key) and use that to create a newdbinstance for each new schema you are interested in querying.