PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » MDB2_Schema » Bug #8043

getDefinitionFromDatabase Missing Indexes

Details

Submitted2006-06-27 11:55 UTC
Frommichael at apison dot com
StatusBogus
PackageMDB2_Schema
PHP Version5.1.4
OSirrelevant
Roadmaps(Not assigned)

Comments

[2006-06-27 11:55 UTC] michael at apison dot com

Description:
------------
Hi there,

I'm having a problem with reverse engineering a database into a schema file. I can't pinpoint the reason, but the table indexes are lost in the reverse. I'm using the mysqli driver. The DDL for the two tables is as follows:

CREATE TABLE `core_request_map` (
`id` int(11) NOT NULL,
`path` varchar(255) NOT NULL default '/',
`view` varchar(40) NOT NULL default 'public',
`module` varchar(40) default NULL,
`action` varchar(40) default NULL,
`params` varchar(255) default NULL,
PRIMARY KEY (`id`),
KEY `module_action_params` (`view`,`module`,`action`,`params`),
KEY `path` (`path`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `core_request_map_attrib` (
`id` int(11) NOT NULL,
`locale` char(5) NOT NULL,
`identifier` varchar(100) NOT NULL,
`title` varchar(100) NOT NULL,
`description` varchar(255) default NULL,
PRIMARY KEY (`id`,`locale`),
KEY `identifier` (`identifier`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Any ideas?

Michael

Test script:
---------------
$dump = $schema->getDefinitionFromDatabase();

$options = array (
'output_mode' => 'default',
'output' => 'schema',
);

echo "<pre>";

$schema->dumpDatabase($dump, $options, MDB2_SCHEMA_DUMP_STRUCTURE);

function schema ($x)
{
echo htmlspecialchars($x);
}

echo "</pre>";

Expected result:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE database SYSTEM "http://cvs.php.net/viewvc.cgi/pear/MDB2_Schema/docs/MDB.dtd?revision=1.3">
<database>
<name>framework</name>
<create>true</create>
<overwrite>false</overwrite>
<table>

<name>core_request_map</name>

<declaration>

<field>
<name>id</name>
<type>integer</type>
<unsigned>true</unsigned>
<length>4</length>
<notnull>true</notnull>
<default/>
</field>

<field>
<name>path</name>
<type>text</type>
<length>255</length>
<notnull>true</notnull>
<default>/</default>
</field>

<field>
<name>view</name>
<type>text</type>
<length>40</length>
<notnull>true</notnull>
<default>public</default>
</field>

<field>
<name>module</name>
<type>text</type>
<length>40</length>
<notnull>false</notnull>
<default/>
</field>

<field>
<name>action</name>
<type>text</type>
<length>40</length>
<notnull>false</notnull>
<default/>
</field>

<field>
<name>params</name>
<type>text</type>
<length>255</length>
<notnull>false</notnull>
<default/>
</field>

<index>
<name>primary</name>
<primary>true</primary>
<field>
<name>id</name>
<sorting>ascending</sorting>
</field>
</index>

<index>
<name>module_action_params</name>
<primary>false</primary>
<field>
<name>view</name>
<sorting>ascending</sorting>
</field>
<field>
<name>module</name>
<sorting>ascending</sorting>
</field>
<field>
<name>action</name>
<sorting>ascending</sorting>
</field>
<field>
<name>params</name>
<sorting>ascending</sorting>
</field>
</index>

<index>
<name>path</name>
<field>
<name>path</name>
<sorting>ascending</sorting>
</field>
</index>

</declaration>

</table>

<table>

<name>core_request_map_attrib</name>

<declaration>

<field>
<name>id</name>
<type>integer</type>
<unsigned>true</unsigned>
<length>4</length>
<notnull>true</notnull>
<default/>
</field>

<field>
<name>locale</name>
<type>text</type>
<length>5</length>
<notnull>true</notnull>
<default/>
</field>

<field>
<name>identifier</name>
<type>text</type>
<length>100</length>
<notnull>true</notnull>
<default/>
</field>

<field>
<name>title</name>
<type>text</type>
<length>100</length>
<notnull>true</notnull>
<default/>
</field>

<field>
<name>description</name>
<type>text</type>
<length>255</length>
<notnull>false</notnull>
<default/>
</field>

<index>
<name>primary</name>
<primary>true</primary>
<field>
<name>id</name>
<sorting>ascending</sorting>
</field>
<field>
<name>locale</name>
<sorting>ascending</sorting>
</field>
</index>

<index>
<name>identifier</name>
<field>
<name>identifier</name>
<sorting>ascending</sorting>
</field>
</index>

</declaration>

</table>
</database>

Actual result:
--------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE database SYSTEM "http://cvs.php.net/viewvc.cgi/pear/MDB2_Schema/docs/MDB.dtd?revision=1.3">
<database>
<name>framework</name>
<create>true</create>
<overwrite>false</overwrite>
<table>

<name>core_request_map</name>

<declaration>

<field>
<name>id</name>
<type>integer</type>
<unsigned>false</unsigned>
<length>4</length>
<notnull>true</notnull>
<default/>
</field>

<field>
<name>path</name>
<type>text</type>
<length>255</length>
<notnull>true</notnull>
<default>/</default>
</field>

<field>
<name>view</name>
<type>text</type>
<length>40</length>
<notnull>true</notnull>
<default>public</default>
</field>

<field>
<name>module</name>
<type>text</type>
<length>40</length>
<notnull>false</notnull>
<default/>
</field>

<field>
<name>action</name>
<type>text</type>
<length>40</length>
<notnull>false</notnull>
<default/>
</field>

<field>
<name>params</name>
<type>text</type>
<length>255</length>
<notnull>false</notnull>
<default/>
</field>

</declaration>

</table>

<table>

<name>core_request_map_attrib</name>

<declaration>

<field>
<name>id</name>
<type>integer</type>
<unsigned>false</unsigned>
<length>4</length>
<notnull>true</notnull>
<default/>
</field>

<field>
<name>locale</name>
<type>text</type>
<length>5</length>
<notnull>true</notnull>
<default/>
</field>

<field>
<name>identifier</name>
<type>text</type>
<length>100</length>
<notnull>true</notnull>
<default/>
</field>

<field>
<name>title</name>
<type>text</type>
<length>100</length>
<notnull>true</notnull>
<default/>
</field>

<field>
<name>description</name>
<type>text</type>
<length>255</length>
<notnull>false</notnull>
<default/>
</field>

</declaration>

</table>
</database>

[2006-06-27 18:00 UTC] michael at apison dot com

Ah, that's a gotcha! thanks for the note.