Jump to content
X2Community Forums

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


Recommended Posts

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!

Link to post
Share on other sites
  • 10 months later...

Hi ibernhardt!

 

The best way to proceed with this is to reserve the id's (56, 57, 58) in the table 'x2_docs'. 

You can conduct an update command to change the id's to a bigger number.

We have resolved this issue in a more recent update! 

 

The other option is to update manually which we do not recommend due to the difficulty. 

 

Hopefully this helps!

 

Sincerely,

Justin 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...