I have a multi-site setup that is working in Drupal 8 (8.6.13) - all of the sites share the code-base and database happily but I cannot seem to share data tables between the sites using the prefix array method - has this changed in Drupal 8 since older versions?
... I start off asking this since most of the data I am finding is for Drupal 7 or older and the solutions given seem valid but are not fully working when I try to implement them.
For example - I want a base (default) site to handle taxonomy, content types, and some admin functions like REST APIs. Each site can handle it's own content and theme (there are no users to worry about) and the sites/multi-site-1/settings.php
is configured to handle this properly (I think).
in the base settings.php
:
$databases['default']['default'] = array(
'database' => 'base_database',
'username' => 'db_user',
'password' => 'db_password',
'prefix' => array(
'default' => 'base_',
// ** content type and fields seem to share okay!
'content_type_' => 'shared_',
'content_field_' => 'shared_',
// ** the other tables with 'shared_' prefix that do not work shown below
and in the sites/multi-site-1/settings.php
:
$databases['default']['default'] = array (
'database' => 'base_database',
'username' => 'db_user',
'password' => 'db_password',
'prefix' => array(
'default' => 'site_1_',
// ** can these even be shared?
// 'config' => 'shared_',
// 'config_snapshot' => 'shared_',
// ** users related things have errors when installing multi-site-1
//'authmap' => 'shared_',
//'profile_fields' => 'shared_',
//'profile_values' => 'shared_',
//'permission' => 'shared_',
//'role' => 'shared_',
//'sessions' => 'shared_', //1. error - if sharing site won't even start install
//'user' => 'shared_', //3. error - "EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY': "
//'users' => 'shared_',
//'users_roles' => 'shared_', //2. error - "The "user_role" entity type does not exist."
//'users_data' => 'shared_', //2. error - "Table users_data already exists"
//'users_field_data' => 'shared_',
// ** taxonomy related share seems okay but not working?
//'taxonomy_index' => 'shared_',
//'taxonomy_term_data' => 'shared_',
//'taxonomy_term_field_data' => 'shared_',
//'taxonomy_term__parent' => 'shared_',
//'vocabulary' => 'shared_', // 1. install error - not present in D8 db?
//'vocabulary_node_types' => 'shared_',
//'term_data' => 'shared_', // not present in D8?
//'term_hierarchy' => 'shared_', // not present in D8?
//'term_image' => 'shared_', // not present - n/a?
//'term_lineage' => 'shared_', // not present - n/a?
//'term_node' => 'shared_', // not present - n/a?
//'term_relation' => 'shared_', // not present - n/a?
//'term_synonym' => 'shared_', // not present - n/a?
),
'host' => 'localhost',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
'collation' => 'utf8mb4_unicode_ci',
);
- Should I abandon the multi-site config in this manner and rely on a contrib module like Domain Access? (I have tried to set this up but cannot seem to get it configured properly - or am not even sure what it is supposed to be doing for me).
- Is this still a good way to share data in the database in Drupal 8 or am I missing something?
- Am I adding in too much of the old v7 and v6 multi-site logic and Drupal 8 handles this differently?
any insights into how to do this better would be greatly appreciated!
some answers already read and referenced: