0

I have an install script for a module which Ive been working on that has previously run perfectly. Since I last used it I have deleted the database, in which it was installed and now want to reuse it.

I accessed the relevant module in my browser then checked my database, the table i am trying to install does not seem to install. I have looked in core_resource to see if there is a record of it in there, but there is no record.

It is my understanding that magento will look at the version number in the config file and compare that to the install file version number and if the version number of the config is greater than the version number of the install file it will look to see if there is a record of that install in the database and if there isn't it will go ahead and install a copy.

The config.xml version number is currently 0.1.0

The install script is currently

sql/namespace_modulename_setup/install-0.1.0.php

Have I misunderstood how Magento is installing tables or am I looking the wrong place or could it be a an error in the install script? if so how would I troubleshoot it?

===EDIT===

I thought I would add some of my code, as there must be an error in that, I am assuming that I have an error with my config due to the install file not even running so I have added that and an image of my filesenter image description here

<config>

<modules>
    <Mdg_Giftregistry>
        <version>0.1.0</version>
    </Mdg_Giftregistry>
</modules>

<global>
    <models>
        <mdg_giftregistry>
            <class>Mdg_Giftregistry_Model</class>
            <resourceModel>mdg_giftregistry_mysql4</resourceModel>
        </mdg_giftregistry>

        <mdg_giftregistry_mysql4>
            <class>Mdg_Giftregistry_Mysql4</class>
            <entities><!-- added on code review-->
                <entity>
                    <table>Mdg_Giftregistry_Entity</table>
                </entity>
                <item>
                    <table>Mdg_Giftregistry_Item</table>
                </item>
                <type>
                    <table>Mdg_Giftregistry_Type</table>
                </type>
            </entities><!-- added on code review-->
        </mdg_giftregistry_mysql4>

        <resources>
            <mdg_giftregistry_setup>
                <setup>
                    <module>Mdg_Giftregistry</module>
                    <class>Mdg_Giftregistry_Model_Resource_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </mdg_giftregistry_setup>

            <mdg_giftregistry_write>
                <use>core_write</use>
            </mdg_giftregistry_write>
            <mdg_giftregistry_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </mdg_giftregistry_read>
        </resources>        
    </models>
.....
</config>
  • 1
    Try renaming install-0.1.0.php to mysql4-install-0.1.0.php. – airhorse Sep 3 '13 at 13:30
  • 1
    Try clearing the cache. @airhorse. there is no need for renaming unless the Magento version is below 1.6. – Marius Sep 3 '13 at 13:31
  • Thanks for your suggestions, I have changed the file name and cache is disabled, but the table has not been installed. I dropped a die() command in to see if the script is being used, and it seems that it is not being used – tony09uk Sep 3 '13 at 14:42
  • In my case this blog helped me. inchoo.net/magento/… – Prashant Apr 11 '17 at 6:21
1

To add table to the database, use setup file in your module.

To insert a new table, please view this video

http://www.youtube.com/watch?v=M-LMInpT0ek

For Magento set up instructions , kindly check this http://alanstorm.com/magento_setup_resources

  • Maybe you could include some content into this answer in the event that those two links move or are deleted in the future? – philwinkle Sep 3 '13 at 17:03
  • The youtube video seems to be talking about adding a table to the front end, not the database? thanks for the link to the Alanstorm tutorial but that was my first port of call to learn this and I have rechecked it prior to placing a question on here, i've obviously misunderstood the tutorial at some point, which is why I have added ho I understand Magento to work in my question, could you advise on where I am going wrong? – tony09uk Sep 4 '13 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.