Thanks Jeremy for the reply. I'm going to play around with this some and
keep it handy if I need to move that direction; hoping that the scoping
will be enough. Thank you again.
Pete
On Sunday, January 22, 2017 at 1:14:46 PM UTC-5, Jeremy Evans wrote:
>
> 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.