Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

mysql4-install problem
 
karlec
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2008-08-26
Argentina
 

Hello everyone:
Create a new module and does not enable me to create the tables it uses. I found that reading the file must be created mysql4-install-0.1.0.php inside the folder / app/code/local/Mage/modulonuevo/sql/modulonuevo_setup/mysql4-install-0.1.0.php.
The module works perfectly (creating tables manually), I just did not create tables, any ideas? I put the code below mysql4-install-0.1.0.php

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * @category   Mage
 * @package    Mage_Paygate
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

$installer $this;
/* @var $installer Mage_Core_Model_Resource_Setup */

$installer->startSetup();

$installer->run("

DROP TABLE IF EXISTS `{
$this->getTable('my_table')}`;
CREATE TABLE IF NOT EXISTS `{
$this->getTable('my_table')}` (
  `id` bigint(20) NOT NULL auto_increment,
  ....
......
.....
PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

DROP TABLE IF EXISTS `{
$this->getTable('my_table')}`;
CREATE TABLE IF NOT EXISTS `{
$this->getTable('my_table')}` (
  `job_code` varchar(10) NOT NULL,
......
......
......
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


"
);

$installer->endSetup();
 
Magento Community Magento Community
Magento Community
Magento Community
 
wdchoi
Jr. Member
 
Total Posts:  20
Joined:  2008-11-17
 

Hi Carlos.

There are two things you need to check.

First, check your config.xml in modulonuevo. You should have something like this in it :

<resources>
            <
modulonuevo_setup>
                <
setup>
                    <
module>Mage_Modulonuevo</module>
// the following class is the Setup Class you should have in 
// Mage/Modulonuevo/Model/Modulonuevo/Setup.php. 
// if you don't have it, copy Mage_Customer_Model_Entity_Setup and clean it
                    
<class>Mage_Model_Modulonuevo_Setup</class> 
                </
setup>
                <
connection>
                    <use>
core_setup</use>
                </
connection>
            </
modulonuevo_setup>
            <
modulonuevo_write>
                <
connection>
                    <use>
core_write</use>
                </
connection>
            </
modulonuevo_write>
            <
modulonuevo_read>
                <
connection>
                    <use>
core_read</use>
                </
connection>
            </
modulonuevo_read>
        </
resources>

Second, go check the database table core_resource. In there are listed all installed module and their version number. If you see your own module in there with 0.1.0 or more written, then it’s normal your install doesn’t get launched… you just have to delete that line, or change the version number, in case you want to run an upgrade.

Don’t forget to clean the cache before launching the installs and upgrades. (empty /var/cache)

That should do it !

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

@azn_david: Actually, In his case, he doesn’t need the setup class at all. 

@Carlos A.:  I would recommend AGAINST putting your module in the same namespace as the core.  You currently have /app/code/local/Mage/modulonuevo you should have that in your own namespace.  For instance /app/code/local/MyCompany/MyModule is the common example you’ll find on the forums.  David’s suggestion is basically correct, however, I have personally started using this form instead

<resources>
    <
MyCompany_MyModule>
        <
setup>
            <
module>MyCompany_MyModule</module>
        </
setup>
        <
connection>
            <use>
core_setup</use>
        </
connection>
    </
MyCompany_MyModule>
    <
mymodule_read>
        <
connection>
            <use>
core_read</use>
        </
connection>
    </
mymodule_read>
    <
mymodule_write>
        <
connection>
            <use>
core_write</use>
        </
connection>
    </
mymodule_write>
</
resources>

Then I put the install scripts (mysql4-install-x.x.x.php and the like) in /app/code/local/MyCompany/MyModule/sql/MyConpamy_MyModule/

Doing it this way, you get an entry in the core_resources table that has your module name, MyCompany_MyModule, instead of mymodule_setup.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top