-
Notifications
You must be signed in to change notification settings - Fork 72
support for multiple entity managers #122
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
Comments
It isn't, no - but why would you want multiple ones (out of curiosity). |
For a multi tenant app where each tenant sits in their own database or schema for example. I'm working on an app right now, where most schemas are the same, but then there are a handful of tenants with completely unique tables. For those you need a separate entity manager each so you can migrate and seed them separately. |
That use-case makes me shiver for all sorts of reasons. lol |
How so? |
Multi-tenant applications across multiple databases is imho a lot harder to manage than a single database that manages the requirements. It just makes me feel itchy :P That's not to say it's not a good use-case for multiple entity managers - certainly it is. |
It's harder, true. Why we switched from MySQL databases to PostgreSQL schemas. The concept is almost the same, but you still get the data separation while keeping things simple for database backups and cross-tenant queries. |
Yeah I guess you're trading one set of issues for another? |
Not really. It works really well if you set your search_path accordingly to make sure that you always have your global schema in there right after the current tenant schema. Then your queries look first in the tenant schema and if it can't find the table there it looks in the global schema. |
If it's all in one schema you wouldn't have to do that, hence previous comment ;) |
Yeah, but keeping all that data from different companies in the same schema makes me cringe. I wouldn't want that for mine. |
Just comes down to good code. Lots of companies do it :) |
Basecamp runs on a single database, to give you an idea. haha |
Not a good enough reason :) Don't use Basecamp. |
hahaha. Well if I were to add to that - running a pretty complex SaaS application myself with the firm I work for - and opting for a single database has its architectural challenges, but it makes a number of things a lot simpler. In either case - we've digressed haha |
I am practicing DDD and as it suggests, you need to divide your application by bounded context. Then each context should have different entity manager. I cant talk more about it since Im not an expert. Here is one example why we wanna use multiple entity managers https://msdn.microsoft.com/en-us/magazine/jj883952.aspx its a .Net implementation though. |
@daskul that's not true at all. Bounded contexts do not necessarily mean a different connection or set of rules. Instead, they set boundaries by which other domains can access each other. |
well then I dont have much argument. but how can you map 2 entities from different bounded context to the same database table? |
@daskul and everyone else please use our new library, laravel-doctrine/orm. It has support for multiple entity managers and much, much more! |
Closing because project is no longer maintained. Thanks. |
Is this feature already supported?
The text was updated successfully, but these errors were encountered: