1

I am trying to upgrade magento 1.5.0.1 to 1.9.3.10 but I am getting the following error every time. I tried going to 1.6.2 as a test but having the same issue:

Error in file: "/app/code/core/Mage/Core/sql/core_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php" - 
SQLSTATE[42000]: Syntax error or access violation: 1171
All parts of a PRIMARY KEY must be NOT NULL; 
if you need NULL in a key, use UNIQUE instead

I've run the DB repair script against a vanilla 1.5.0.1 and all is fine.

Has anyone come across this issue before?

  • Was your Magento 1.5.0.1 was fully patched before running the upgrade? – Mukesh Apr 30 at 16:58
0

In file app\code\core\Mage\Core\sql\core_setup\/mysql4-upgrade-1.5.9.9-1.6.0.0.php look for INDEX_TYPE_UNIQUE and try to find some duplicate values for specific tables. I would supect some problem with core_url_rewrite (column id_path)

0

In table core_cache_tag you have to change the default value of columns tag and cache_id to a empty value ('') since they are both primary keys and not null.

This worked for me:

ALTER TABLE `core_cache_tag` 
CHANGE `tag` `tag` VARCHAR(100) NOT NULL DEFAULT '', 
CHANGE `cache_id` `cache_id` VARCHAR(200) NOT NULL DEFAULT '';
0

Updated solution

Turns out all these issues are due to the current versions of php and mysql being incompatible with magento 1.6, be certain to use the old versions of php and mysql and that may solve your issue.

Manual bypass solution

The issue is at lib/Varien/Db/Adapter/Pdo/Mysql.php line 1108 where it sets nullable=true when it shouldn't.

I was updating to version 1.6.0.0 but I expect the issue is similar.

just wrap an if statement around it to prevent the error

if ($options['TABLE_NAME'] != 'salesrule_product_attribute' && $options['COLUMN_NAME'] != 'website_id') {
    $columnDefinition['nullable'] = true;
}

the original script assumes that since the foreign key can nullify the website_id when the original website_id is deleted that it is safe to assume that NULL is an acceptable default value. Obviously someone made a mistake setting up the original foreign key relationship since a primary key can't contain a null value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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