2012/05/01

Can't create table: eav_prefix_text , Integrity constraint violation: 1452 Cannot add or update a child row

http://www.magentocommerce.com/bug-tracking/issue/?issue=12126
http://www.magentocommerce.com/bug-tracking/issue/?issue=12336


Error :
(For magento 1.6 bug)
I encountered the same problem. In my situation I realized that the error occurring when trying to create the database table was: BLOB/TEXT column 'value' used in key specification without a key length
To force Magento to render SQL statements that my database could accept, I had to modify the app/code/core/Mage/Eav/Model/Entity/Setup.php file at approximately line 1337 (inside the createEntityTables method). Replacing the following lines:

        ->addIndex($this->getIdxName($eavTableName, array('attribute_id', 'value')),
            array('attribute_id', 'value'))
        ->addIndex($this->getIdxName($eavTableName, array('entity_type_id', 'value')),
            array('entity_type_id', 'value'))
 
With this:
 

 ->addIndex($this->getIdxName($eavTableName, array('entity_id')),  
                array('entity_id'));  

                if ($eavTableName[1] != 'text')  
                {  

                $eavTable->addIndex($this->getIdxName($eavTableName, array('attribute_id', 'value')),  
                array('attribute_id', 'value'))  
                ->addIndex($this->getIdxName($eavTableName, array('entity_type_id', 'value')),  
                array('entity_type_id', 'value'));  
                }  
 
 
 On the other hand, there is also an error for magento1.6:
Was also getting an error
-- Integrity constraint violation: 1452 Cannot add or update a child row magento
 

 
Had to remove the entity_id FK constraint (removing the ->addForeignKey... entity_id)

The createEntityTables() method Mage_Eav_Model_Entity_Setup creates FK's
 in the type sub-tables pointing at $this->getTable('eav/entity') 
instead of $baseTableName.


replace 
//                ->addForeignKey($this->getFkName($eavTableName, 'entity_id', 'eav/entity', 'entity_id'),
//                    'entity_id', $this->getTable('eav/entity'), 'entity_id',
//                    Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
//                

with this:

 $eavTable->addForeignKey($this->getFkName($eavTableName, 'entity_id', 'eav/entity', 'entity_id'),  
'entity_id', $baseTableName, 'entity_id',  
Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)


 



  

沒有留言:

發佈留言