Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a large SQL file. Can I use this in my module installer?

share|improve this question
up vote 9 down vote accepted

Yes, if you follow the naming conventions for install scripts. For example:


Or as data install script (if you are not adding/changing tables):


You need to define the setup resource your_module_setup and the current version number in the module's config.xml like this:


Clarification: Magento looks for files with this pattern that either end in ".php" or ".sql", you should only have one of them per upgrade, but not both.

If you want to know how they are executed, see Mage_Core_Model_Resource_Setup::modifyResourceDb()

share|improve this answer
Is it ".sql" or ".php" ? – Vicky Dev Jan 11 at 10:20
sql. Magento looks for both and treats them accordingly – fschmengler Jan 11 at 10:20
Thanks for info. Just for clarification, if ".sql" then only we can use mysql queries syntaxes in it, and if ".php" then both mysql and php, right ? – Vicky Dev Jan 11 at 10:22
That's correct. – fschmengler Jan 11 at 10:25
Thank's ! Working with the SQL file now. Great answer – Kurdt94 Jan 11 at 15:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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