This will show you how to add another table to your custom module after it has already been created.
To add another table open the modules/[your module]/classes/Maps.xml file.
You will see something like this.
<!DOCTYPE maps SYSTEM "../../../lib/tools/dtd/MapsDefinition2.0.dtd"> <maps> <map> <map-name>UserinfoMap</map-name> <schema> <schema-major>1</schema-major> <schema-minor>0</schema-minor> </schema> <member> <member-name>id</member-name> <member-type>INTEGER</member-type> <member-size>SMALL</member-size> <primary/> </member> <member> <member-name>userId</member-name> <member-type>STRING</member-type> <member-size>MEDIUM</member-size> </member> </map> </maps>
Between the </map> and </maps> you add your other table like so:
<map> <map-name>UserinfoSetupMap</map-name> <schema> <schema-major>1</schema-major> <schema-minor>0</schema-minor> </schema> <member> <member-name>uiPerPage</member-name> <member-type>INTEGER</member-type> <member-size>SMALL</member-size> <primary/> </member> <member> <member-name>uiDefaultSortColumn</member-name> <member-type>STRING</member-type> <member-size>MEDIUM</member-size> </member> <member> <member-name>uiDefaultSortOrder</member-name> <member-type>STRING</member-type> <member-size>MEDIUM</member-size> </member> </map>
The End Result of your modules/[your module]/classes/Maps.xml will look similar to this:
<!DOCTYPE maps SYSTEM "../../../lib/tools/dtd/MapsDefinition2.0.dtd"> <maps> <map> <map-name>UserinfoMap</map-name> <schema> <schema-major>1</schema-major> <schema-minor>0</schema-minor> </schema> <member> <member-name>id</member-name> <member-type>INTEGER</member-type> <member-size>SMALL</member-size> <primary/> </member> <member> <member-name>userId</member-name> <member-type>STRING</member-type> <member-size>MEDIUM</member-size> </member> </map> <map> <map-name>UserinfoSetupMap</map-name> <schema> <schema-major>1</schema-major> <schema-minor>0</schema-minor> </schema> <member> <member-name>uiPerPage</member-name> <member-type>INTEGER</member-type> <member-size>SMALL</member-size> <primary/> </member> <member> <member-name>uiDefaultSortColumn</member-name> <member-type>STRING</member-type> <member-size>MEDIUM</member-size> </member> <member> <member-name>uiDefaultSortOrder</member-name> <member-type>STRING</member-type> <member-size>MEDIUM</member-size> </member> </map> </maps>
After having changed the Map / Entity definition and having created an A_[table-name]_[major].[minor].xml file for upgrades, you're now ready to generate the new SQL.
In the command line, you enter:
cd modules/[your module]/classes/ make
Verify that the SQL has been generated correctly by looking at modules/[your module]/classes/GalleryStorage/schema.tpl. The CREATE TABLE statement should now reflect the new table structure and there should be a new ALTER TABLE statement too.
You then need to open your modules/[your module]/module.inc file:
Find:
$this->setVersion('1.0.2');
and increase the version number accordingly.
$this->setVersion('1.0.3');
The above table name, columns name, and version # are only examples.