Posted by Sylvain Lecoy on July 30, 2010 at 6:25pm
5 followers
Jump to:
| Project: | Schema |
| Version: | 6.x-1.7 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | matason |
| Status: | postponed (maintainer needs more info) |
Issue Summary
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.
Comments
#1
Sorry, actually its working but the schema module put as missing all the shared stuff.
#2
Sorry my explanation was very bad.
When I set my $db_prefix to have multi databases:
<?php$db_prefix = array(
'default' => 'web1.',
'users' => 'web_shared.',
'sessions' => 'web_shared.',
'role' => 'web_shared.',
'authmap' => 'web_shared.',
);
?>
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
#3
Hi,
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
#4
I put this as critical since Schema module will not work on any database configuration that is not trivial.
#5
I have some time this evening so I'll take a look.
#6
Here'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:
$db_prefix = array('main' => 'd6.',
'users' => 'someotherdb.',
);
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?
#7
same 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.
#8
matason I will try your process, and give you a "step to reproduce this bug" guide as soon as I have time.
#9
Hello, 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:
<?php$db_prefix = array(
'main' => 'prefix_',
'users' => '????',
);
?>
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.
#10
Hi sempotcool, Sylvain Lecoy,
Here's the help comment from settings.php regarding $db_prefix:
* You can optionally set prefixes for some or all database table names* by using the $db_prefix setting. If a prefix is specified, the table
* name will be prepended with its value. Be sure to use valid database
* characters only, usually alphanumeric and underscore. If no prefixes
* are desired, leave it as an empty string ''.
*
* To have all database names prefixed, set $db_prefix as a string:
*
* $db_prefix = 'main_';
*
* To provide prefixes for specific tables, set $db_prefix as an array.
* The array's keys are the table names and the values are the prefixes.
* The 'default' element holds the prefix for any tables not specified
* elsewhere in the array. Example:
*
* $db_prefix = array(
* 'default' => 'main_',
* 'users' => 'shared_',
* 'sessions' => 'shared_',
* 'role' => 'shared_',
* 'authmap' => 'shared_',
* );
*
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:
<?php$db_prefix = array(
'default' => 'web1.',
'users' => 'web_shared.',
'sessions' => 'web_shared.',
'role' => 'web_shared.',
'authmap' => 'web_shared.',
);
?>
...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?
#11
I have the same problem. I have in settings.php:
$db_url = array(
'default' => 'mysqli://xy@localhost/shop',
'shared' => 'mysqli://xy@localhost/shared',
);
$db_prefix = array(
'default' => 'shop.',
'authmap' => 'shared.',
'role' => 'shared.',
'sessions' => 'shared.',
'users' => 'shared.',
);
Drupal works fine but Schema compare shows 4 missing tables (which are in second shared DB used also for another sites):
Tables in the schema that are not present in the database.system
* sessions
user
* authmap
* role
* users
How may I correct this in Schema module?
#12
I would suggest using an underscore rather than a . (dot) to prefix tables.