On Saturday, January 21, 2017 at 10:21:22 PM UTC-8, Peter Washburn wrote:
>
> I'm looking to separate each tenant into their own schema on a single 
> database with the exact same table definitions; is there a way to specify 
> the schema the model reads and writes from? My goal is to create the new 
> schema at the time the user creates their account. I'm currently just 
> scoping all data to protect each tenant's , but I'm prepping for a 
> requirement of the data not coexisting.  
> Thanks Pete


Currently I think you could do something like this:

  class Foo < 
Sequel::Model(DB.from(Sequel.delay{Sequel[Thread.current[:current_schema]||:public][:foos]}))
  end

Then you can just set Thread.current[:current_schema] on a per request 
basis (e.g. rack middleware or before filter).

Note that I've never done anything like this in production, so I'm not sure 
what issues you will run into (if any).

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to