title: Problem with resource setup in magento
body: <p>Apologize for the lengthy post in advance. </p>
  
  <p>I was following Alan Storm's articles about magento development. I was following the part 6 in that series about Resource setup. I created the resource setup in the config file and placed the Setup.php file appropriately. But if i try to flush the cache or try to access any page of magento, i get a error message : There has been an error processing your request. If i remove the setup part from the config file, everything works perfectly again. Here are my files :
  Config.xml file </p>
  
  <pre><code>&lt;config&gt;    
      &lt;modules&gt;
          &lt;Foostor_Weblog&gt;
              &lt;version&gt;0.1.0&lt;/version&gt;
          &lt;/Foostor_Weblog&gt;
      &lt;/modules&gt;
      &lt;frontend&gt;
          &lt;routers&gt;
              &lt;weblog&gt;
                  &lt;use&gt;standard&lt;/use&gt;
                  &lt;args&gt;
                      &lt;module&gt;Foostor_Weblog&lt;/module&gt;
                      &lt;frontName&gt;weblog&lt;/frontName&gt;
                  &lt;/args&gt;
              &lt;/weblog&gt;
          &lt;/routers&gt;
      &lt;/frontend&gt; 
      &lt;global&gt;
          &lt;models&gt;
          &lt;weblog&gt;
              &lt;class&gt;Foostor_Weblog_Model&lt;/class&gt;
              &lt;!-- 
              need to create our own resource, cant just
              use core_mysql4
              --&gt;
              &lt;resourceModel&gt;weblog_mysql4&lt;/resourceModel&gt;
          &lt;/weblog&gt; 
          &lt;weblog_mysql4&gt;
              &lt;class&gt;Foostor_Weblog_Model_Mysql4&lt;/class&gt;
              &lt;entities&gt;
                  &lt;blogpost&gt;
                      &lt;table&gt;blog_posts&lt;/table&gt;
                  &lt;/blogpost&gt;
              &lt;/entities&gt;
          &lt;/weblog_mysql4&gt;
      &lt;/models&gt;
      &lt;resources&gt;
          &lt;weblog_setup&gt;
              &lt;setup&gt;
                  &lt;module&gt;Foostor_Weblog&lt;/module&gt;
                  &lt;class&gt;Foostor_Weblog_Model_Resource_Setup&lt;/class&gt;
              &lt;/setup&gt;
              &lt;connection&gt;
                  &lt;use&gt;core_setup&lt;/use&gt;
              &lt;/connection&gt;
          &lt;/weblog_setup&gt;
          &lt;weblog_write&gt;
              &lt;connection&gt;
                  &lt;use&gt;core_write&lt;/use&gt;
              &lt;/connection&gt;
          &lt;/weblog_write&gt;
          &lt;weblog_read&gt;
              &lt;connection&gt;
                  &lt;use&gt;core_read&lt;/use&gt;
              &lt;/connection&gt;
          &lt;/weblog_read&gt;      
      &lt;/resources&gt;
      &lt;/global&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p>This the Setup.php file:
      </p>
  
  <p>Also in the reports in var/reports folder, i found this error message : </p>
  
  <pre><code>a:5:{i:0;s:102:"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'weblog_setup' for key 'PRIMARY'";i:1;s:1493:"#0 C:\wamp\www\magento\lib\Zend\Db\Statement.php(300): Zend_Db_Statement_Pdo-&gt;_execute(Array)
  #1 C:\wamp\www\magento\lib\Zend\Db\Adapter\Abstract.php(479): Zend_Db_Statement-&gt;execute(Array)
  #2 C:\wamp\www\magento\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract-&gt;query('INSERT INTO `co...', Array)
  #3 C:\wamp\www\magento\lib\Varien\Db\Adapter\Pdo\Mysql.php(337): Zend_Db_Adapter_Pdo_Abstract-&gt;query('INSERT INTO `co...', Array)
  #4 C:\wamp\www\magento\lib\Zend\Db\Adapter\Abstract.php(574): Varien_Db_Adapter_Pdo_Mysql-&gt;query('INSERT INTO `co...', Array)
  #5 C:\wamp\www\magento\app\code\core\Mage\Core\Model\Mysql4\Resource.php(96): Zend_Db_Adapter_Abstract-&gt;insert('core_resource', Array)
  #6 C:\wamp\www\magento\app\code\core\Mage\Core\Model\Resource\Setup.php(290): Mage_Core_Model_Mysql4_Resource-&gt;setDbVersion('weblog_setup', '0.1.0')
  #7 C:\wamp\www\magento\app\code\core\Mage\Core\Model\Resource\Setup.php(233): Mage_Core_Model_Resource_Setup-&gt;_upgradeResourceDb('0', '0.1.0')
  #8 C:\wamp\www\magento\app\code\core\Mage\Core\Model\Resource\Setup.php(161): Mage_Core_Model_Resource_Setup-&gt;applyUpdates()
  #9 C:\wamp\www\magento\app\code\core\Mage\Core\Model\App.php(399): Mage_Core_Model_Resource_Setup::applyAllUpdates()
  #10 C:\wamp\www\magento\app\code\core\Mage\Core\Model\App.php(329): Mage_Core_Model_App-&gt;_initModules()
  #11 C:\wamp\www\magento\app\Mage.php(627): Mage_Core_Model_App-&gt;run(Array)
  #12 C:\wamp\www\magento\index.php(80): Mage::run('', 'store')
  #13 {main}";s:3:"url";s:48:"/magento/index.php/weblog/index/showAllBlogPosts";s:11:"script_name";s:18:"/magento/index.php";s:4:"skin";s:7:"default";}
  </code></pre>
  
  <p>I found in a few posts that Integrity constraint violation can be avoided by clearing the contents of Log_* tables in the magento db. But i am not sure if this is what i need to do. Kindly advice. Thanks.</p>