-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Shared Applications #1
Comments
+1 this model sounds workable, thanks, L |
Could the INSTALLED_APPS list be populated differently based on what syncdb mode (parameter) is running? |
I'm not sure, but I think I did try that and the problem is that django 2013/2/2 Stefán Baxter notifications@github.com
Bernardo Pires Carneiro |
hmmm, can we try again? I am willing to look into the syncdb part if you are willing to look into the rest. |
sure, let's try it mate! 2013/2/2 Stefán Baxter notifications@github.com
Bernardo Pires Carneiro |
I will create SHARED_APPS and TENANT_APPS which will produce different results in INSTALLED_APPS for syncdb based on a parameter reflected in settings.SYNCDB_MODE = 'public' or 'tenant' and will then include both when the parameter is missing. (I think that will at least get us started) |
Perfect! 2013/2/2 Stefán Baxter notifications@github.com
Bernardo Pires Carneiro |
Ok, I have it working (I think). I will create a fork in a little while (dinner) and create a pull request. |
Ok, I did something as simple as wrapping the syncdb command with INSTALLED_APPS manipulation based on two settings (--tenant or --shared) and I have verified that it creates only the corresponding tables. Is that enough? |
Hi Stefán, yes, that is exactly the way I had in mind! That's perfect! How did you get 2013/2/2 Stefán Baxter notifications@github.com
Bernardo Pires Carneiro |
Hi, it's there along with the pull request. You will need to change the way new tenant domains are initiated if this is to work properly. |
Hi Stéfan, many thanks for the exciting patch!! I'll look onto it as soon 2013/2/3 Stefán Baxter notifications@github.com
Bernardo Pires Carneiro |
Hope it's soon. I'd really like to start using this :) |
Stefan, I'd like your input on something. I think there may be a need for having models that are
|
Understand, this should be a simple addition. |
Hi, The way it works now is that SHARED_APPS are public-exclusive (shared) and I would think that the different south modes are controlled with I'm not to familiar with south but would belong in both groups so it's Regards, On Mon, Feb 4, 2013 at 6:21 PM, Bernardo Pires Carneiro <
|
Hi, Ultimately this approach uses the ._meta.managed setting to affect which For me this is a straight forward approach and relies on a setting which is Manipulating this setting is trivial* and it +connection.set_tenant(tenant, *just remember to put it back in its original state and don't manipulate Regards, On Mon, Feb 4, 2013 at 6:44 PM, Stefan Baxter stebax@gmail.com wrote:
|
I ran your command setting the verbosity of syncdb to 3 and it seems like 2013/2/4 Stefán Baxter notifications@github.com
Bernardo Pires Carneiro |
Yes, all models are validated. The manage switch then stops it from
|
Ok, it seems it was a bug on my side. --shared seems to work perfectly now, 2013/2/4 Bernardo Carneiro carneiro.be@gmail.com
Bernardo Pires Carneiro |
Alright, everything seems to be working now. It was again a mistake on my 2013/2/4 Stefán Baxter notifications@github.com
Bernardo Pires Carneiro |
fine, use this anyway you like :) On Mon, Feb 4, 2013 at 7:43 PM, Bernardo Pires Carneiro <
|
I still need to update the docs but your patch is in! Don't forget to send your patch for the other issue you solved: #3 |
Yes, all models are validated. The manage switch then stops it from I ran your command setting the verbosity of syncdb to 3 and it seems like 2013/2/4 Stefán Baxter notifications@github.com
Bernardo Pires Carneiro — Reply to this email directly or view it on |
Hey Stefan, your last message turned out weird. Is everything working as you wanted? |
Have not tried it yet, but I think so (looking at the code) :) On Tue, Feb 5, 2013 at 7:01 AM, Bernardo Pires Carneiro <
|
docs have been updated, I'll close this issue if you don't find any problem :) |
great, thnx! On Tue, Feb 5, 2013 at 10:49 AM, Bernardo Pires Carneiro <
|
Can I close this issue or do you have any other concern? |
I'm fine :) |
check db wrapper subclases in dbrouter
Move to a middleware only based solution, no new settings required.
An application is considered to be shared when it's table are in the
public
schema. Some apps make sense being shared. Suppose you have some sort of public data set, for example, a table containing census data. You want every tenant to be able to query it.Right now, this is not possible, at least not in practical way. By default all models are being synced to every schema, including
public
. Please take a look at the tenant-schemas needs your help! section if you have an idea on how to do this.django-appschema
tries to solve this in a very hackish and dangerous way by altering django's app cache. This is not safe for on-the-fly creation of tenants, so this is not an option. django-schemata partially solves it by forcing you to move your shared tables to thepublic
schema. When syncing the tables for tenant-specific applications, the search path is set topublic
plus the tenant's schema, which means all tables that already exist onpublic
will not be created when syncing. This is not ideal because it doesn't allow you have to applications that are both shared and tenant-specific. For example, you may need to have a user system for your main domain and another for your tenants. Or you may want to havesouth
in both.To enable this, an idea would be to let all models, both shared and tenant-specific to be synced. After the sync, the unnecessary models can be deleted from the database. There would be three arrays,
SHARED_APPS
,TENANT_APPS
andMUTUAL_APPS
. For example, when syncing thepublic
schema, we can just iterate overTENANT_APPS
deleting their tables. When syncing tenants, we delete theSHARED_APPS
tables. We can then enable the tenants to also see thepublic
schema. This is of course not very elegant, but shouldn't present a big hit on performance (how often do you sync your models?) and doesn't involve hacking django's cache.An ever simpler solution would be if it were possible to select which models have to be synced. AFAIK this is not possible, syncdb is called for all models on
INSTALLED_APPS
.What do you think of this solution? Do you have a better idea? Please send in your feedback!
The text was updated successfully, but these errors were encountered: