0

I have a few Drupal 7 sites running on a multisite setup. They each have their own database, and there's a "shared" database used by all of them, which contains user data, date formats, filters and some other data that is shared across all of the sites.

Nodes and taxonomy are not shared, but I am looking at changing that so they are, and using a taxonomy vocab as a means of specifying which site each node is associated with.

I don't have a problem setting that up as I have a nice little database include that handles database credentials and prefixing, but there is one drawback with this setup and that is controlling which database any given module should create new tables in. I know that in order to have all sites use a single node table, I should also share the content types and fields - but I am going to run into issues when creating new fields on content types, as their respective tables will naturally be created in the site's default database and not the shared one.

So, I suppose my question is: how can I specify what the default database should be on a per-module basis?

P.S. I did consider using Domain Access to achieve this, but that doesn't seem to be suitable in this case as each site uses a separate database already, and I'm not looking to share themes, site config, blocks, views, panel data, paths, etc.

1 Answer 1

2

Unfortunately, Drupal was not designed to work this way. The only way to figure out where to put each table would be to carefully inspect each new module and adjust your settings in advance of enabling the module. Even if you manage to do this, you are likely to run into problems with modules that stores critical information in the variables table. Clearly you cannot share the entire variables table, so you would instead need to figure out how to synchronize individual values that must be shared, avoid race conditions, etc.

You should strongly consider using domain access or subdomain to share node content between different sites. You will have some work ahead of you in converting from your current site format to one that will work for you; the migrate module may help with this task.

1
  • I see. I was hoping it would be possible via hooks (and maybe even custom Rules - i.e. "if module X is doing something in the database, switch the active DB to {shared}") - but I hadn't even thought of the implications with variables. I will see how far I can get with Domain Access. Thanks.
    – Riari
    Oct 18, 2012 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.