Jump to content


Photo

Integrity constraint violation: 1062 Duplicate entry '56' for key 'PRIMARY'


  • Please log in to reply
2 replies to this topic

#1 foxthorn

foxthorn

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 06 November 2018 - 05:31 AM

I'm updating from 6.5.1 to 7.0. 

I found other posts related to similar error but it doesn't appear that the issue I'm having is related to x2_dropdowns.

 

Integrity constraint violation: 1062 Duplicate entry '56' for key 'PRIMARY'

 

I actually tired looking at the primary key of all tables and could not find a duplicate '56' entry.

I believe the error is happening on this sql command since it is the next one to execute after the list shown of working commands prior to the error.

 

ALTER TABLE `x2_admin` ADD COLUMN `dropboxCredentialsId` int(10) unsigned NULL AFTER `twitterCredentialsId`,

ADD COLUMN `linkedInCredentialsId` int(10) unsigned NULL AFTER `dropboxCredentialsId`,

ADD COLUMN `linkedInRateLimits` text NULL AFTER `twitterRateLimits`,

ADD COLUMN `dropboxRateLimits` text NULL AFTER `linkedInRateLimits`,

MODIFY COLUMN `maxUserCount` int(11) NULL DEFAULT '200' AFTER `timeout`,

ADD INDEX `linkedInCredentialsId` (`linkedInCredentialsId`) USING BTREE,

ADD INDEX `dropboxCredentialsId` (`dropboxCredentialsId`) USING BTREE,

ADD CONSTRAINT `x2_admin_ibfk_dropbox` FOREIGN KEY `x2_admin_ibfk_dropbox` (`dropboxCredentialsId`)

REFERENCES `x2_credentials` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,

ADD CONSTRAINT `x2_admin_ibfk_google1` FOREIGN KEY `x2_admin_ibfk_google1` (`googleCredentialsId`)

REFERENCES `x2_credentials` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, ADD CONSTRAINT `x2_admin_ibfk_linkedIn` FOREIGN KEY `x2_admin_ibfk_linkedIn` (`linkedInCredentialsId`) REFERENCES `x2_credentials` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;

 

Full error message list:

 

A database change failed to apply: protected/migrations/6.9/1501616097-mail-templates.php. 17 changes were applied prior to this failure:

  1. ALTER TABLE `x2_locations` MODIFY COLUMN `altitude` float DEFAULT NULL, MODIFY COLUMN `accuracy` float DEFAULT NULL, MODIFY COLUMN `altitudeAccuracy` float DEFAULT NULL, MODIFY COLUMN `heading` float DEFAULT NULL, MODIFY COLUMN `speed` float DEFAULT NULL, MODIFY COLUMN `type` varchar(50) DEFAULT NULL;
  2. CREATE TABLE `x2_twofactor_auth` ( `userId` int(11) NOT NULL, `code` varchar(6) NOT NULL, `requested` bigint(20) NOT NULL, PRIMARY KEY (`userId`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  3. ALTER TABLE `x2_actions` ADD INDEX `locationId` (`locationId`) USING BTREE;
  4. ALTER TABLE `x2_admin` ADD COLUMN `enableGeolocation` tinyint(4) NULL DEFAULT '1' AFTER `enableWebTracker`, ADD COLUMN `hubCredentialsId` int(10) unsigned NULL AFTER `jasperCredentialsId`, ADD COLUMN `twoFactorCredentialsId` int(10) unsigned NULL AFTER `hubCredentialsId`, ADD COLUMN `disableAnonContactNotifs` tinyint(4) NULL DEFAULT '0' AFTER `twoFactorCredentialsId`;
  5. ALTER TABLE `x2_events` ADD COLUMN `recordLinks` text NULL AFTER `locationId`, ADD INDEX `locationId` (`locationId`) USING BTREE;
  6. ALTER TABLE `x2_locations` ADD COLUMN `seen` text NULL AFTER `comment`, DROP COLUMN `contactId`;
  7. ALTER TABLE `x2_profile` ADD COLUMN `enableTwoFactor` tinyint(4) NULL DEFAULT '0' AFTER `defaultCalendar`;
  8. ALTER TABLE `x2_tags` ADD INDEX `itemId` (`itemId`) USING BTREE;
  9. ALTER TABLE `x2_web_forms` ADD COLUMN `thankYouText` text NULL AFTER `requireCaptcha`;
  10. INSERT INTO `x2_auth_item` (`bizrule`,`data`,`description`,`name`,`type`) VALUES (NULL,'N;','Permissions for integrating the application with X2 Hub Services.','AdminX2HubIntegration',0),(NULL,'N;','','UsersDeactivateTwoFactor',0),(NULL,'N;','','ActionsGetAutocompleteAssocLink',0);
  11. INSERT INTO `x2_auth_item_child` (`child`,`parent`) VALUES ('UsersDeactivateTwoFactor','UsersAdminAccess'),('ActionsGetAutocompleteAssocLink','ActionsMinimumRequirements'),('AdminX2HubIntegration','GeneralAdminSettingsTask');
  12. ALTER TABLE `x2_admin` ADD COLUMN `maxUserCount` int(11) NULL DEFAULT '100000' AFTER `timeout`, ADD COLUMN `loginCredsTimeout` int(11) NULL DEFAULT '30' AFTER `maxUserCount`, ADD COLUMN `tokenPersist` tinyint(4) NULL DEFAULT '1' AFTER `loginCredsTimeout`, ADD COLUMN `checkinByDefault` tinyint(4) NULL DEFAULT '1' AFTER `locationTrackingSwitch`;
  13. ALTER TABLE `x2_modules` ADD COLUMN `linkOpenInFrame` tinyint(4) NULL DEFAULT '0' AFTER `linkOpenInNewTab`;
  14. ALTER TABLE `x2_relationships` ADD INDEX `firstId` (`firstId`) USING BTREE, ADD INDEX `secondId` (`secondId`) USING BTREE;
  15. ALTER TABLE `x2_web_forms` ADD COLUMN `fingerprintDetection` tinyint(4) NULL DEFAULT '1' AFTER `requireCaptcha`;
  16. INSERT INTO `x2_auth_item` (`bizrule`,`data`,`description`,`name`,`type`) VALUES (NULL,'N;','General max user count for the application.','AdminManageUserCount',0),(NULL,'N;','','AdminLocateMissingRecords',0),(NULL,'N;','','MarketingValidate',0);
  17. INSERT INTO `x2_auth_item_child` (`child`,`parent`) VALUES ('AdminManageUserCount','GeneralAdminSettingsTask'),('AdminLocateMissingRecords','GeneralAdminSettingsTask'),('MarketingValidate','MarketingBasicAccess');

Please save the above list. 

The error message given was: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '56' for key 'PRIMARY'

The database has been restored to the backup copy.


Update failed.

 

Thanks for any help you can provide!



#2 X2Peter

X2Peter

    Advanced Member

  • Administrators
  • 57 posts

Posted 07 November 2018 - 01:00 PM

I believe this is occurring due to a default template for docs that was included during the 6.9 update. You may need to perform the update manually via the instructions given here: http://wiki.x2crm.co...pdates_Manually



#3 foxthorn

foxthorn

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 08 November 2018 - 03:12 PM

I had just two documents in my DB so I changed their IDs to 1000 and 1001 and now the update worked correctly.

Thanks so much for you guidance!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users