-
Notifications
You must be signed in to change notification settings - Fork 0
Multi-tenancy support! (WIP) #146
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
base: google-auth
Are you sure you want to change the base?
Conversation
backend/src/application/app_core.py
Outdated
| if tenant_id: | ||
| g.tenant_id = tenant_id | ||
| else: | ||
| g.tenant_id = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is it, "2"?
backend/src/application/app_core.py
Outdated
|
|
||
| def _store_tenant_id_in_context(): | ||
| g.tenant_id = None | ||
| tenant_id = request.headers.get("X-Tenant-ID") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the PR is not complete, because I don't see how this value gets supplied from the frontend or something, right?
backend/src/database/tenant.py
Outdated
| # Call the original filter method with the provided criteria | ||
| query = super(TenantScopedQuery, self).filter(*criteria) | ||
|
|
||
| logging.error(f"Query: {query}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it .error?
| query_class = TenantScopedQuery | ||
|
|
||
| # Assuming every table has a 'company_id' field | ||
| company_id = db.Column(db.Integer, nullable=False, index=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it needed here really? I see this company_id in all the descendants of this table which overwrite this one. I'd say yes, it is needed, but why do we have tons of company_id = db.Column(db.Integer, db.ForeignKey('company.id', ondelete='SET NULL'), server_default="1", nullable=False) here and there if we can put this line directly into this class?
backend/src/database/tenant.py
Outdated
|
|
||
| def filter_by(self, **kwargs): | ||
| logging.error(f"Filter by kwargs: {kwargs}") | ||
| super(TenantScopedQuery, self).filter_by(**kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this method return something?
…nant() when no filters in query & add filter_by to db.session.query calls
# Conflicts: # backend/src/application/app_core.py # backend/src/application/schemas.py
No description provided.