Call-back icon  Sales: Call 877.832.5289 (N America)|310.295.4144 (International)

Magento

eCommerce Software for Online Growth

Magento Forum

   
Resolving SQL Error
 
Greg Randall
Jr. Member
 
Total Posts:  6
Joined:  2008-04-03
 

in mysql4-upgrade-0.8.10-0.8.11.php, the first MYSQL statement caused a MYSQL error as it was trying to remove a foreign key that didn’t exist on our Magento database.

The website would not load.

Removing this first line and keeping the second MYSQL statement resolved the error.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Justin Beasley
Jr. Member
 
Total Posts:  1
Joined:  2008-04-09
 

I receive a number of these errors everytime I update.  The scripts that are running aren’t needed (the DB structure is already updated), so I have to move all the old upgrade scripts out of the directory to keep them from throwing errors.

I’d love to hear if there’s some way to fix this issue.

 
Magento Community Magento Community
Magento Community
Magento Community
 
schmelzgeist
Sr. Member
 
Total Posts:  92
Joined:  2008-05-27
Marzipane World Capital (Lübeck, Germany)
 
Greg Randall - 15 September 2008 02:54 PM

in mysql4-upgrade-0.8.10-0.8.11.php, the first MYSQL statement caused a MYSQL error as it was trying to remove a foreign key that didn’t exist on our Magento database.

The website would not load.

Removing this first line and keeping the second MYSQL statement resolved the error.

i think i have the same MysqlError :

PDOException Object
(
    
[message:protected] => SQLSTATE[HY000]General error1025 Error on rename of './magento10/design_change' to './magento10/#sql2-74cc-6505d' (errno152)
    
[string:private] => 
    
[code:protected] => HY000
    [file
:protected] => /home/httpd/docs/show/magento/lib/Varien/Db/Adapter/Pdo/Mysql.php
    [line
:protected] => 150
    [trace
:private] => Array
        (
            
[0] => Array
                (
                    
[file] => /home/httpd/docs/show/magento/lib/Varien/Db/Adapter/Pdo/Mysql.php
                    [line] 
=> 150
                    [function] 
=> query
                    [class] 
=> PDO
                    [type] 
=> ->
                    
[args] => Array
                        (
                            
[0] => ALTER TABLE `design_changeDROP FOREIGN KEY `FK_DESIGN_CHANGE_STORE`
                        )

                )

            
[1] => Array
                (
                    
[file] => /home/httpd/docs/show/magento/lib/Varien/Db/Adapter/Pdo/Mysql.php
                    [line] 
=> 212
                    [function] 
=> raw_query
                    [class] 
=> Varien_Db_Adapter_Pdo_Mysql
                    [type] 
=> ->
                    
[args] => Array
                        (
                            
[0] => ALTER TABLE `design_changeDROP FOREIGN KEY `FK_DESIGN_CHANGE_STORE`
                        )

                )

            
[2] => Array
                (
                    
[file] => /home/httpd/docs/show/magento/app/code/core/Mage/Core/Model/Resource/Setup.php
                    [line] 
=> 493
                    [function] 
=> multi_query
                    [class] 
=> Varien_Db_Adapter_Pdo_Mysql
                    [type] 
=> ->
                    
[args] => Array
                        (
                            
[0] => 
ALTER TABLE `design_changeDROP FOREIGN KEY `FK_DESIGN_CHANGE_STORE`;
ALTER TABLE `design_change`
  
ADD CONSTRAINT `FK_DESIGN_CHANGE_STOREFOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE;

                        )

                )

            
[3] => Array
                (
                    
[file] => /home/httpd/docs/show/magento/app/code/core/Mage/Core/sql/core_setup/mysql4-upgrade-0.8.10-0.8.11.php
                    [line] 
=> 36
                    [function] 
=> run
                    [class] 
=> Mage_Core_Model_Resource_Setup
                    [type] 
=> ->
                    
[args] => Array
                        (
                            
[0] => 
ALTER TABLE `design_changeDROP FOREIGN KEY `FK_DESIGN_CHANGE_STORE`;
ALTER TABLE `design_change`
  
ADD CONSTRAINT `FK_DESIGN_CHANGE_STOREFOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE;

                        )

                )

            
[4] => Array
                (
                    
[file] => /home/httpd/docs/show/magento/app/code/core/Mage/Core/Model/Resource/Setup.php
                    [line] 
=> 268
                    [args] 
=> Array
                        (
                            
[0] => /home/httpd/docs/show/magento/app/code/core/Mage/Core/sql/core_setup/mysql4-upgrade-0.8.10-0.8.11.php
                        
)

                    
[function] => include
                )

            
[5] => Array
                (
                    
[file] => /home/httpd/docs/show/magento/app/code/core/Mage/Core/Model/Resource/Setup.php
                    [line] 
=> 178
                    [function] 
=> _modifyResourceDb
                    [class] 
=> Mage_Core_Model_Resource_Setup
                    [type] 
=> ->
                    
[args] => Array
                        (
                            
[0] => upgrade
                            [1] 
=> 0.8.10
                            [2] 
=> 0.8.11
                        
)

                )

            
[6] => Array
                (
                    
[file] => /home/httpd/docs/show/magento/app/code/core/Mage/Core/Model/Resource/Setup.php
                    [line] 
=> 145
                    [function] 
=> _upgradeResourceDb
                    [class] 
=> Mage_Core_Model_Resource_Setup
                    [type] 
=> ->
                    
[args] => Array
                        (
                            
[0] => 0.8.10
                            [1] 
=> 0.8.11
                        
)

                )

 Signature 

WE have no future because our Present is too volatile.We have only riskmanagement.
The spinning of the given moment´s scenario. *Pattern Recognition.W.Gibson*

 
Magento Community Magento Community
Magento Community
Magento Community
 
Michael
Magento Team
 
Total Posts:  684
Joined:  2007-08-31
 

Replacing the following lines in app/code/core/Mage/Core/sql/core_setup/mysql4-upgrade-0.8.10-0.8.11.php :

$installer->run("
ALTER TABLE `{$installer->getTable('design_change')}` DROP FOREIGN KEY `FK_DESIGN_CHANGE_STORE`;
ALTER TABLE `{$installer->getTable('design_change')}`
  ADD CONSTRAINT `FK_DESIGN_CHANGE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$installer->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE;
"
);

with

$installer->getConnection()->dropForeignKey($installer->getTable('design_change'), 'FK_DESIGN_CHANGE_STORE');
$installer->getConnection()->addConstraint(
    
'FK_DESIGN_CHANGE_STORE',
    
$installer->getTable('design_change'), 'store_id',
    
$installer->getTable('core_store'),    'store_id'
);

should help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
schmelzgeist
Sr. Member
 
Total Posts:  92
Joined:  2008-05-27
Marzipane World Capital (Lübeck, Germany)
 

thanks, it did. smile

 Signature 

WE have no future because our Present is too volatile.We have only riskmanagement.
The spinning of the given moment´s scenario. *Pattern Recognition.W.Gibson*

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
Sales: Call 877.832.5289 (North America) 310.295.4144 (International)
© Copyright 2008 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
52294 users|448 users currently online|105616 forum posts