when you set the $db_prefix like this:
<?php
$db_prefix = array(
'default' => 'web1.',
'users' => 'web_shared.',
'sessions' => 'web_shared.',
'role' => 'web_shared.',
'authmap' => 'web_shared.',
);
?>
Schema module put all the tables in extra and does not work as expected.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | 869796-support-prefixes.patch | 4.64 KB | dave reid |
| #18 | 869796-support-prefixes.patch | 1.39 KB | dave reid |
| #15 | schema_mysql_2.patch | 2.2 KB | rimen |
| #14 | schema_mysql.patch | 2.08 KB | rimen |
Comments
Comment #1
sylvain lecoy commentedSorry, actually its working but the schema module put as missing all the shared stuff.
Comment #2
sylvain lecoy commentedSorry my explanation was very bad.
When I set my $db_prefix to have multi databases:
The schema module fire an error that the tables are not present in the database. This is somewhat true because its in another database. How can we configure/change the way the module is looking for another database ?
-- Schema Module comparison report --
Missing (5)
Tables in the schema that are not present in the database.
system
sessions
user
authmap
role
users
Comment #3
Anonymous (not verified) commentedHi,
To add to this, I'm currently in a situation where I have 6 databases in 1 but with different prefixes so as to be able to share tables. Now, the tables I had at last count were 947 and it runs fine, after disabling the status (MySQL level) so as to disable it reporting on the admin page www.domain.tld/admin. It gets so bad, MySQL dies as entries into the database are recorded. And the server has to be reset.
If this is not disabled, it keeps bringing the site down and another annoying thing and I am not sure about the source yet, is that the status resets itself every so often so have to keep an eye on this tables all the time.
How can we disable reporting completely? Schema is required in this case and we cannot do without it.
Help.
Kahenya
Comment #4
sylvain lecoy commentedI put this as critical since Schema module will not work on any database configuration that is not trivial.
Comment #5
matason commentedI have some time this evening so I'll take a look.
Comment #6
matason commentedHere's what I did in an attempt to recreate the issue:
Installed a fresh Drupal 6 (I named the database 'd6'), installed schema 6.x-1.7, edited my settings.php and set my $db_prefix as follows:
The 'someotherdb' was from a previous Drupal 6 installation, to confirm my $db_prefix was working I went to admin/user/user and sure enough, the users from the 'someotherdb' database showed up.
Even after clearing the cache all tables appeared in the 'Match' fieldset, no tables appeared in 'Missing'.
Can you spot anything I am missing in my process that would prevent the error showing up? If not, can you confirm you get the error when you perform the same process as I have done here?
Comment #7
sempotcool commentedsame issue for me, 3 databases and the module indicates that 82 out of 102 tables are missing (so 20 tables needs to be deleted), i'll try to set the $db_prefix.
Comment #8
sylvain lecoy commentedmatason I will try your process, and give you a "step to reproduce this bug" guide as soon as I have time.
Comment #9
sempotcool commentedHello, It's me again, Sorry but I don't understand how $db_prefix works, i have 3 db : prefix_code1, prefix_code2, prefix_code3, do I put:
and in place of "prefix_code1" I write "code1" in the settings.php?
I installed the module on another of my sites with just 1 db and it works like a charm, thx.
May I suggest to add the possibility to delete tables and fix errors directly from the module configuration page without opening phpmyadmin.
Comment #10
matason commentedHi sempotcool, Sylvain Lecoy,
Here's the help comment from settings.php regarding $db_prefix:
My understanding then of $db_prefix is that it serves several purposes:
a) It enables you to run several Drupal sites using one database - this is achieved by setting $db_prefix = 'a_' in your settings.php file for site a and $db_prefix = 'b_' in your settings.php file for site b etc.
b) It enables you set prefixes for specific tables which in turn enables you to share certain tables between Drupal sites - you could set site b to share the users table by setting $db_prefix = array('default' => 'b_', 'users' => 'a_'); in your settings.php on site b.
c) Other usages?
Sylvain Lecoy's usage of $db_prefix above was new to me, I am not sure whether $db_prefix was designed to be used that way, the instructions in settings.php I quoted above state:
However, using a . (dot) appears to work, it would still prefix the table (if you included something after the .) and additionally it specifies the database name to use - so the $db_prefix configuration from the initial report:
...would use un-prefixed tables (there's nothing following the . there) from a database called web1 except for tables users, sessions, role and authmap for which it would use un-prefixed tables in a database called web_shared. I guess this would only work if the user/pass was the same for both databases or would you have to set $db_url = array('web1' => 'mysql://username:password@localhost/web1', 'web_shared' => 'mysql://username:password@localhost/web_shared'); ??? I don't know off hand...
From a quick look at the code in Drupal 7 it appears that using a . in $db_prefix is fully supported.
Well I don't know whether that sheds any light on anything?
Comment #11
kjuro commentedI have the same problem. I have in settings.php:
Drupal works fine but Schema compare shows 4 missing tables (which are in second shared DB used also for another sites):
How may I correct this in Schema module?
Comment #12
matason commentedI would suggest using an underscore rather than a . (dot) to prefix tables.
Comment #13
sssmmm commentedI have the same problem but to more detail about the issue ..
Database is not default data in the prefix .. but its an external database in same server alongside Drupal Default .. so adding prefix with dot (.) make the query to external database .. where underscore will not work ..
in this case when you compare schema .. it say table is missing ..
$db_url = array(
'default' => 'mysqli://xy@localhost/shop',
'shared' => 'mysqli://xy@localhost/shared', >>>>>>>> database is shared not the default Drupal one ..
);
$db_prefix = array(
'default' => 'shop.',
'authmap' => 'shared.', >>>>>>> this table will be queried as shared.authmap in Druapal instead of default ..
'role' => 'shared.',
'sessions' => 'shared.',
'users' => 'shared.',
);
For sure you need to select the correct database in the setting of schema to see the correct table in compare tab .. but problem is when some other module call for this function compareSchema() .. it show tables as missing which are coming from non default databases ..
I hope it clear your confusions ..
Comment #14
rimen commentedI have the same multisite arhitecture: several databases is used for shared and custom tables.
My settings.php config of "Main" site:
included patch solve this problem for me.
It check database configuration array of prefixes for databases references (like "shared.", @see default.settings.php) and include them in table select queries.
Comment #15
rimen commentedCorrected patch
Please, ignore previous #14
Comment #16
dave reidMarked #1488842: Schema reports 'EXTRA' tables, for tables that are not 'drupal' tables as a duplicate of this issue.
Comment #18
dave reidI think this should be the proper way to support the prefixes using information we can collect easily.
Comment #20
dave reidFixed test to actually use drupal_get_schema() so this will actually give us a better picture of how testing works.
Comment #21
dave reidCommitted #18 to 7.x-1.x: http://drupalcode.org/project/schema.git/commit/64c6631
Comment #23
dave reid