Magento 1.8 – Custom Module Not Creating New Table

magento-1.8

magento\app\etc\modules\Svi_Form.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Svi_Form>
            <active>true</active>
            <codePool>local</codePool>
        </Svi_Form>
    </modules>
</config>

app\code\local\Svi\Form\controllers\IndexController.php

<?php
Class Svi_Form_IndexController extends Mage_Core_Controller_Front_Action{
    public function indexAction(){
        $layout =$this->loadLayout();
        $this->renderLayout();
    }

    public function postAction(){
        $post = $this->getRequest()->getPost();
        print_r($post);exit;
    }

}
?>

app\code\local\Svi\Form\etc\config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Svi_Form>
            <version>0.1.0</version>
        </Svi_Form>
    </modules>

    <frontend>
        <routers>
            <form>
                <use>standard</use>
                <args>
                    <module>Svi_Form</module>
                    <frontName>form</frontName>
                </args>
            </form>
        </routers>
        <layout>
            <updates>
                <form>
                    <file>form.xml</file>
                </form>
            </updates>
        </layout>
    </frontend>
    <global>
        <models>
            <form>
                <class>Svi_Form_Model</class>
                <resourceModel>form_mysql4</resourceModel>
            </form>
            <form_mysql4>
                <class>Svi_Form_Model_Mysql4</class>
                <entities>
                    <form>
                        <table>svi_form</table>
                    </form>
                </entities>
            </form_mysql4>
        </models>
        <resources>
            <form_setup>
                <setup>
                    <module>Svi_Form</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </form_setup>
            <form_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </form_write>
            <form_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </form_read>
        </resources>
        <blocks>
            <form>
                <class>Svi_Form_Block</class>
            </form>
        </blocks>
        <helpers>
            <form>
                <class>Svi_Form_Helper</class>
            </form>
        </helpers>
    </global>
</config>

app\code\local\Svi\Form\Block\Form.php

<?php
class Svi_Form_Block_Form extends Mage_Core_Block_Template 
{   

}

app\code\local\Svi\Form\Helper\Data.php

<?php
class Svi_Form_Helper_Data extends Mage_Core_Helper_Abstract
{

}

app\code\local\Svi\Form\Model\Form.php

<?php
class Svi_Form_Model_Form extends Mage_Core_Model_Abstract
{
    public function _construct()
    {
        parent::_construct();
        $this->_init('form/form');
    }
}

app\code\local\Svi\Form\Model\Mysql4\Form.php

<?php
class Svi_Form_Model_Mysql4_Form extends Mage_Core_Model_Mysql4_Abstract
{
    public function _construct()
    {   
        $this->_init('form/form', 'prical_id');
    }
}

app\code\local\Svi\Form\Model\Mysql4\Form\Collection.php

<?php
class Svi_Form_Model_Mysql4_Form_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
    public function _construct()
    {
        //parent::__construct();
        $this->_init('form/form');
    }
}

app\code\local\Svi\Form\sql\form_setup\mysql4-install-0.1.0.php

<?php
$installer = $this;

$installer->startSetup();

$installer->run("

-- DROP TABLE IF EXISTS {$this->getTable('svi_form')};
CREATE TABLE {$this->getTable('svi_form')} (
  `prical_id` int(11) unsigned NOT NULL auto_increment,
  `title` varchar(255) NOT NULL default '',
  `content` text NOT NULL default '',
  `status` smallint(6) NOT NULL default '0',
  `created_time` datetime NULL,
  `update_time` datetime NULL,
  PRIMARY KEY (`prical_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    ");

$installer->endSetup();

Please tell me what is my mistake here. It is not createing table. I am new on Magento that's why I asked this question. Thanks………….

Best Answer

Delete the setup entry (for this module) in core_resource table

Disable the cache.

Refresh any page

Check the database

I have checked your code it working fine. Just disable cached or flush the cached

Related Topic