0

Is there a way to force the install scripts to run for every new deployment? When I deploy a new git branch to our QA servers, the install scripts are not kicking off since magento thinks they already ran. I can fix it manually by removing the necessary rows from the core_resource table and refresh the page. I would like to be able to do this programmatically as a part of our deployment process without specifying core_resource rows that can be added or changed by our developers.

1 Answer 1

1

You are using versioning system so whenever you deploy you should create upgrade script and increase your version of module that will automatically re-run sql scripts and no need any change in core_resource.

For First deployment of same module

Your first module file in app/etc/modules/Namespace_Module.xml will lool like.

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

Next you have to define same version at app/code/local/Namespace/Module/config.xml will look like.

<?xml version="1.0"?>
<config>
  <modules>
    <Namespace_Module>
      <version>1.0.0</version>
    </Namespace_Module>
  </modules>

And setup script should look like app/code/local/Namespace/Module/sql/module_setup/install-1.0.0.php will look like.

<?php  
$installer = $this;
$installer->startSetup();

//Your sql script

$installer->endSetup();

For Next deployment of same module

Your module file in app/etc/modules/Namespace_Module.xml will lool like. Increased version.

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

Next you have to update version in app/code/local/Namespace/Module/config.xml will look like. Increased version.

<?xml version="1.0"?>
<config>
  <modules>
    <Namespace_Module>
      <version>1.0.1</version>
    </Namespace_Module>
  </modules>

And setup script should look like app/code/local/Namespace/Module/sql/module_setup/upgrade-1.0.0-1.0.1.php will look like. I have just changed setup script name that upgrade-{Previous version}-{New version}.php it will recognize by magento and it will run sql script without changing in core_resource table

<?php  
$installer = $this;
$installer->startSetup();

//Your sql script

$installer->endSetup();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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