Creating a new table in magento using the installer issue
Question
I have created a module, but now i need to create a table in db. this is the content of the Mynamespace/Mymodule/sql/mynamespace_mymodule_setup/mysql4-install-0.1.0.php:
<?php
/* @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
echo 1; exit();
$installer->startSetup();
$table = $installer->getConnection()
->newTable($installer->getTable('mynamespace_mymodule/mytablename'))
->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true,
), 'Id')
->addColumn('check', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
'nullable' => false,
), 'Check')
$installer->getConnection()->createTable($table);
$installer->endSetup();
this is the content of the config.xml file:
<config>
<modules>
<Mynamespace_Mymodule>
<version>0.1.0</version>
</Mynamespace_Mymodule>
</modules>
<global>
<models>
<mynamespace_mymodule>
<class>Mynamespace_Mymodule_Model</class>
<resourceModel>mynamespace_mymodule_mysql4</resourceModel>
</mynamespace_mymodule>
<mynamespace_mymodule_mysql4>
<class>Mynamespace_Mymodule_Model_Mysql4</class>
<entities>
<mytablename>
<table>mynamespace_mymodule_mytablename</table>
</mytablename>
</entities>
</mynamespace_mymodule_mysql4>
</models>
<resources>
<mynamespace_mymodule_setup>
<setup>
<module>Mynamespace_Mymodule</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</mynamespace_mymodule_setup>
<mynamespace_mymodule_write>
<connection>
<use>core_write</use>
</connection>
</mynamespace_mymodule_write>
<mynamespace_mymodule_read>
<connection>
<use>core_read</use>
</connection>
</mynamespace_mymodule_read>
</resources>
</global>
As you see I put an exit in after $installer. It never goes there. Something is wrong with my xml file. Can you help me with this ? thx
Solution
if there is a record in core_resource
with the column core
= 'mynamespace_mymodule_setup' the installer scripts won't run again. Delete that record and clear the cache
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange