Skip to content

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

Closed
jaimesangcap opened this issue Apr 19, 2015 · 19 comments
Closed

support for multiple entity managers #122

jaimesangcap opened this issue Apr 19, 2015 · 19 comments

Comments

@jaimesangcap
Copy link

Is this feature already supported?

@kirkbushell
Copy link
Collaborator

It isn't, no - but why would you want multiple ones (out of curiosity).

@boris-glumpler
Copy link

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.

@kirkbushell
Copy link
Collaborator

That use-case makes me shiver for all sorts of reasons. lol

@boris-glumpler
Copy link

How so?

@kirkbushell
Copy link
Collaborator

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.

@boris-glumpler
Copy link

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.

@kirkbushell
Copy link
Collaborator

Yeah I guess you're trading one set of issues for another?

@boris-glumpler
Copy link

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.

@kirkbushell
Copy link
Collaborator

If it's all in one schema you wouldn't have to do that, hence previous comment ;)

@boris-glumpler
Copy link

Yeah, but keeping all that data from different companies in the same schema makes me cringe. I wouldn't want that for mine.

@kirkbushell
Copy link
Collaborator

Just comes down to good code. Lots of companies do it :)

@kirkbushell
Copy link
Collaborator

Basecamp runs on a single database, to give you an idea. haha

@boris-glumpler
Copy link

Not a good enough reason :) Don't use Basecamp.

@kirkbushell
Copy link
Collaborator

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

@jaimesangcap
Copy link
Author

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.

@kirkbushell
Copy link
Collaborator

@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.

@jaimesangcap
Copy link
Author

well then I dont have much argument. but how can you map 2 entities from different bounded context to the same database table?

@FoxxMD
Copy link
Contributor

FoxxMD commented May 18, 2015

@daskul and everyone else please use our new library, laravel-doctrine/orm. It has support for multiple entity managers and much, much more!

@mitchellvanw
Copy link
Owner

Closing because project is no longer maintained. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants