bernardopires / django-tenant-schemas

Tenant support for Django using PostgreSQL schemas.
https://django-tenant-schemas.readthedocs.org/en/latest/
MIT License
1.44k stars 425 forks source link

tenant schemas issues #616

Open dhirajshinde121083 opened 4 years ago

dhirajshinde121083 commented 4 years ago

I am writing one application for vehicle tracking for one of the companies there are various department(garbage collection(swm),health,encrochment,fire brigade) in that company among which vehicles are divided, for each department vehicle has different duty to perform e.g 1>garbage collection department i will have to track each garbage collecting vehicle and see to it if it is completing its duty properly and collecting bins and emptying it at garbage depot 2>vehicle(ambulance) in health department i need to keep track of route of ambulance (to check if it is following one with least time) 3>encroachment department vehicle to conduct anti encroachment drive

so in short i have vehicles in separate department with separate to do task for each department vehicle

following is my db design i am following one database and many schema approach each schema is for each department so my schema list is as follows 1> public 2> swm 3> healthcare 4> encroachment

each schema will have common tables like 1> vehicle 2> tracklog_history(which contain all position of vehicle which i will be receiving from device fixed on them) 3> activity_log (which contain all position of vehicle where vehicle halted for some purpose, getting this information through speed)

now above schema contain all separate tables

1> swm => vehicle,activity_log,bin,route,stop_points,tracklog_history 2> health => vehicle,tracklog_history,(and other respective operational tables) 3> encroachment => vehicle,tracklog_history,(and other respective operational tables)

now to write the application in django, i have written separate tenant per schema(per department) and added application(named as department from settings.py) which contain information(domain_url,schema_name) about each department to app which is included in the shared app(hereby with this i have attached screenshot of settings.py as setting.png)

I managed to configure separate url for a schema e.g swm.abc.com healthcare.abc.com encrochment.abc.com

for each of this url i want to create application named "admin" (like the one shown in menu.png) which is basically for back office staff of each department to import data in respective department system

e.g. swm->admin is one which is shown in image will have submenu(bin,vehicle,route) to import swm relevant data health->admin will have submenu data(vehicle,hospitals) to import health relevant data

I have the following questions

1> AS per docs of tenant_schemas you will have to create two section "SHARED_APP" AND "INSTALLED_APP" in settings.py now if I include new app "admin" in "SHARED_APP" (since it is going to be common across all the departments to import or add data to respective department by back office) if my admin app models.py contains all tables for swm(vehicle,bin,route), and then i migrate admin app those tables will be created for all departments, which i don't want, as each department will have separate set of tables to operate with( if models.py of admin contains bin then that will be only applicable for swm not for other healthcare )

e.g vehicle for swm is different than vehicle for health(in database swm.vehicle and healthcare.vehicle is different)

bin table will only be part of swm not healthcare schema

2> how do i write tenant specific application so when if migrated it will create tables for respective tenant(respective schema) e.g if i am writing admin app for health and migrate that it should only create tables for healthcare tenant (healthcare schema)

3> in short how do i create separate admin app for all schemas(swm,healthcare,encroachment) which will have different models.py under it (which contain tables definition for respective schmas) on migrate of which respective tables will be created in respective schemas ?

help would be appreciated

Thanks

settings menubar

NotANormalNerd commented 4 years ago

It is not possible with this library to write tenant specific apps and is probably out of scope.