Hello,
I'm trying to export the database schema for a non-default application that we have. I have added the database to settings.php, and when I go to content->schema->settings, I can select the database from the dropdown, but when I go to the inspect tab, it only shows the following with no structure:
This page shows the live database schema as it currently exists on this system. Known tables are grouped by the module that defines them; unknown tables are all grouped together.
To implement hook_schema() for a module that has existing tables, copy the schema structure for those tables directly into the module's hook_schema() and return $schema.
without any database schema.
I also find that the compare tab shows "Missing(75)" and "Extra(0)" so it does not seem to be querying the database.
Any ideas on how I can resolve this issue?
Drupal:7.22
MySQL:Ver 14.14 Distrib 5.5.29, for debian-linux-gnu (x86_64) using readline 6.2
PHP:PHP 5.3.10-1ubuntu3.6 with Suhosin-Patch (cli) (built: Mar 11 2013 14:31:48)
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 1985942-engine-connection-query.patch | 8.38 KB | dave reid |
| #8 | 1985942-engine-connection-query.patch | 8.32 KB | dave reid |
| #7 | 1985942-engine-connection-query.patch | 6.82 KB | dave reid |
| #6 | 1985942-engine-connection-query.patch | 6.69 KB | dave reid |
| #4 | 1985942-engine-connection-query.patch | 3.81 KB | dave reid |
Comments
Comment #1
sjs205 commentedI managed to get around this problem using the following steps:
A bit of a hack, but it worked for me.
:)
Comment #2
heine commentedIf you believe this to be a bug, then your workaround did not fix it.
FWIW, I cannot reproduce this. However, when either a default key is missing for the alternate db array or the database name is misspelled (ie db doesn't exist), I see similar behaviour as the OP; only missing, no extra tables.
I'd expect an error message instead.
Comment #3
dave reidThis is actually correct. The code inside the actual schema engines runs db_query(), which by nature only runs on the default Drupal database. So if you are trying to inspect a MySQL table not on the same server, or a different database type (PostgreSQL from MySQL in Drupal), things fail miserably.
Comment #4
dave reidPlease test the following patch. This fixes major bugs I had trying to inspect a PosgreSQL table from a MySQL Drupal install.
Comment #5
dave reidI don't think this will full resolve things. The major problem is that schema_dbobject() will always return the engine class of the Drupal install, and not actually the engine of the connection that you want to inspect. This is a major, major bug.
Comment #6
dave reidOk I think this should do it. This adds an optional parameter to schema_dbobject() for the connection to use. This ensures that the proper database connection object is passed into the class. This means that the first parameter of the inspect() method is no longer used and is deprecated. This is good, because it ensures that the schema classes actually use the passed in connection object.
Comment #7
dave reidCorrected patch. Has been tested with all admin screens.
Comment #8
dave reidManaged to make this fully backwards-compatible. This should be ready to go.
Comment #9
dave reidOne last attempt to simplify schema_dbobject() and it's uses.
Comment #10
dave reidCommitted #9 to 7.x-1.x
http://drupalcode.org/project/schema.git/commit/9b2856b
For the original report: keep in mind the 'Inspect' tab can only compare the selected database with your current, installed version of Drupal's hook_schema() implementations(). I just tested this with a connection set to my old Drupal 6 database and the Inspect tab does show what I would expect how the tables are different between Drupal 6 and 7.