1

I need to create a single sql install script for all the tables.

Say i have 10 tables defined in config xml.

Need idea on how my Model class should look like and also an example to add more than 10 tables in my install script in magento.

I have tried in script as:

$installer = $this;

$installer->startSetup();
$table = $installer->getConnection()

//For 1st table

->newTable($installer->getTable('vendor_namespace/table1'))
->addColumn('table1Col1', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
    'nullable'  => false,
    ), 'Table 1');
$installer->getConnection()->createTable($table);

 //For 2nd table

->newTable($installer->getTable('vendor_namespace/table2'))
->addColumn('table2Col1', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
    'nullable'  => false,
    ), 'Table 1');
$installer->getConnection()->createTable($table);

//For 3rd table...

1) My doubt is : If i have to change any Primary or foreign key relation, or add/delete any table, i just need to change the version number in both config and script with updated table name or should i create new script file with updated version number.

2) Basically for eg: can i keep reusing the same file mysql4-install-3.2.0.0.php as just mysql4-install-3.2.0.1.php, mysql4-install-3.2.0.2.php and so on.

3) If so, how to keep the record of the previous table structures?

Browse other questions tagged or ask your own question.