makinacorpus/DbToolsBundle

[Question] Multi Tenancy/DB handling

Opened this issue · 2 comments

Hello I'm really interested in this bundle but I have some question I can't really seem to find in the docs

I'm using https://github.com/RamyHakam/multi_tenancy_bundle to manage multi databases dynamically
How would I go about using the backup/restore features given that DB credentials are stored in the main app DB ?

That's a very interesting question. I'll try to answer to it the best I can.

TL;DR: This wasn't a planned feature until now, so there is no documentation. But, now that we know, it may become a new planned feature. But hey, please take so time to read below as well!

First, I didn't even knew about this bundle, it seems interesting. Still since we didn't knew it existed, we didn't have planned to integrate to it. Nevertheless, if it's not hacking too ugly around Doctrine, it should be relatively easy to seamlessly integrate with it.

One important thing, in the middle of our library, there is a component called the "database session registry", it's an interface. Basically, it gives you a list of database connection, along with their names, and which one is default. This is the center of all things, and our entry point if we want to fetch database connections another way.

So, as stated upper, the database connection source can be pretty much anything, as long as we can convert the underlaying connection to a makinacorpus/query-builder database session (so this include PDO connections, Doctrine connections, and in the future, some more such as ext-pgsql connections).

If the multi tenancy bundle does things right, it should be almost trivial to write a new database session registry instance for it.

As I expect to have some in-between client contracts in the next few days or weeks, I'll maybe try to integrate with it (no promises here, it'll much depend on my motivation and on the work stumbling upon me, or on my other colleagues).

As always, we are opened to new feature requests and pull requests, so any contribution of you will be welcomed (and opening a discussing a feature request is a contribution in itself, you are not forced to code anything).

Thanks for the detailed answer.

I'll try to read the code when I have time and figure out how it works internally and maybe try a draft PR or at least write some specs on how I'd imagine the workflow to be.