Skip to content
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

Run-time change of schema #4473

WNemencha opened this issue Jul 22, 2019 · 2 comments

Run-time change of schema #4473

WNemencha opened this issue Jul 22, 2019 · 2 comments


Copy link

@WNemencha WNemencha commented Jul 22, 2019

Hey guys,

sorry to not follow the issue template but it's more a feature request than an issue. Also I'm in a BIG rush actually.

We currently have our boss doing a demo in 1h of our new product which is based on TypeORM with Nest, and it got crazy because we are in a multi-tenant architecture, and TypeORM doesn't support to dynamically change the schema on a per-request basis. Which is something we can't live without. We can't afford to strip away TypeORM to switch to another one with schema support (cause it'll probably makes me fired). As a side note, we use the query methods (find, findAll, etc), not the query builder.

Any "easy" or atleast, possible, solution to this guys?

I've seen this commit, which looks interesting IMO: nurikabe@fa8270e

This issue is related too: #3067

Can someone points me toward the right direction please? I could move every query method to an actual SQL query but it will take super long time to do so...

Thanks in advance, please excuse my lack of issue template.


This comment has been minimized.

Copy link

@felixhayashi felixhayashi commented Aug 11, 2019

bump. it would be great to reuse the connection and just switch the schema when using the entity manager for multi-tenant situations. Having to resort to the QueryBuilder-style just to set the schema would increase complexity and bloat the code.

Something like this would be great:

const manager = connection.createEntityManager({ schema: request.tenantDomain });
manager.findOne(MyEntity, { id: 3 }) // now searches this entity in schema  defined above.

This comment has been minimized.

Copy link

@aaronfulkerson aaronfulkerson commented Aug 25, 2019

bump. this would be a killer feature. would it be possible to store a list of schema names somewhere in a table (or configuration file) and then create/synchronize each of those schemas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.