Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x]: Applying the project config results in integrity constraint violation: 1062 Duplicate entry #16194

Closed
MoritzLost opened this issue Nov 22, 2024 · 3 comments
Labels

Comments

@MoritzLost
Copy link
Contributor

What happened?

Description

I'm trying to apply the project config in a particular branch. The branch contains a new entry type and single. I had previously checked out this branch and applied it (successfully) to review it, then went back to another branch. So the section, entry type and entry are likely still in my database, but were soft-deleted. No when I switch to that branch, I get the following error when running project-config/apply:

error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '11792-2' for key 'z_elements_sites.z_idx_mhnejcpudnkcaamrlakeugzflampecplvutv'
The SQL being executed was: INSERT INTO `z_elements_sites` (`elementId`, `siteId`, `title`, `slug`, `uri`, `enabled`, `content`, `dateCreated`, `dateUpdated`, `uid`) VALUES (11792, 2, 'Volltextsuche', 'volltextsuche', 'volltextsuche', 1, '{\"9c59b580-c617-4ec2-845d-6f445a846e83\":[],\"1fbfd2cb-1209-442c-b8d2-b48ecf6a7feb\":\"2.6667\",\"facc10bc-cca3-4432-8758-4dbda6faa279\":[\"show_caption\",\"show_credits\"],\"9dfaed65-a190-40c6-9b4d-10d3e552472a\":[]}', '2024-11-22 12:02:06', '2024-11-22 12:02:06', '4934e0dd-b31c-42a3-afbd-cd848f42bb85')
Failed to run craft up: exit status 1

Here's the full stack trace:

2024-11-22 13:00:08 [console.ERROR] [yii\db\IntegrityException] PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '11792-2' for key 'z_elements_sites.z_idx_mhnejcpudnkcaamrlakeugzflampecplvutv' in /var/www/html/vendor/yiisoft/yii2/db/Command.php:1320
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1320): PDOStatement->execute()
#1 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1120): yii\db\Command->internalExecute()
#2 /var/www/html/vendor/yiisoft/yii2/db/Schema.php(431): yii\db\Command->execute()
#3 /var/www/html/vendor/yiisoft/yii2/db/ActiveRecord.php(604): yii\db\Schema->insert()
#4 /var/www/html/vendor/yiisoft/yii2/db/ActiveRecord.php(570): yii\db\ActiveRecord->insertInternal()
#5 /var/www/html/vendor/yiisoft/yii2/db/BaseActiveRecord.php(688): yii\db\ActiveRecord->insert()
#6 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(3770): yii\db\BaseActiveRecord->save()
#7 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(1222): craft\services\Elements->craft\services\{closure}()
#8 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(3591): craft\services\Elements->ensureBulkOp()
#9 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(4133): craft\services\Elements->_saveElementInternal()
#10 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(3810): craft\services\Elements->_propagateElement()
#11 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(1222): craft\services\Elements->craft\services\{closure}()
#12 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(3591): craft\services\Elements->ensureBulkOp()
#13 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(1308): craft\services\Elements->_saveElementInternal()
#14 /var/www/html/vendor/craftcms/cms/src/services/Entries.php(1011): craft\services\Elements->saveElement()
#15 /var/www/html/vendor/craftcms/cms/src/services/Entries.php(867): craft\services\Entries->_ensureSingleEntry()
#16 /var/www/html/vendor/craftcms/cms/src/base/ApplicationTrait.php(1829): craft\services\Entries->handleChangedSection()
#17 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(1179): craft\console\Application->craft\base\{closure}()
#18 [internal function]: craft\services\ProjectConfig->handleChangeEvent()
#19 /var/www/html/vendor/yiisoft/yii2/base/Component.php(641): call_user_func()
#20 /var/www/html/vendor/craftcms/cms/src/models/ProjectConfigData.php(82): yii\base\Component->trigger()
#21 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(1169): craft\models\ProjectConfigData->commitChanges()
#22 [internal function]: craft\services\ProjectConfig->handleChangeEvent()
#23 /var/www/html/vendor/yiisoft/yii2/base/Component.php(641): call_user_func()
#24 /var/www/html/vendor/craftcms/cms/src/models/ProjectConfigData.php(82): yii\base\Component->trigger()
#25 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(1289): craft\models\ProjectConfigData->commitChanges()
#26 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(1311): craft\services\ProjectConfig->craft\services\{closure}()
#27 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(627): craft\services\ProjectConfig->_applyChanges()
#28 /var/www/html/vendor/craftcms/cms/src/console/controllers/ProjectConfigController.php(328): craft\services\ProjectConfig->applyExternalChanges()
#29 [internal function]: craft\console\controllers\ProjectConfigController->actionApply()
#30 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#31 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#32 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction()
#33 /var/www/html/vendor/craftcms/cms/src/console/ControllerTrait.php(88): yii\console\Controller->runAction()
#34 /var/www/html/vendor/craftcms/cms/src/console/Controller.php(216): craft\console\Controller->traitRunAction()
#35 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): craft\console\Controller->runAction()
#36 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction()
#37 /var/www/html/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction()
#38 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(212): craft\console\Application->runAction()
#39 /var/www/html/vendor/craftcms/cms/src/console/Controller.php(207): yii\base\Controller->run()
#40 /var/www/html/vendor/craftcms/cms/src/console/controllers/UpController.php(76): craft\console\Controller->run()
#41 [internal function]: craft\console\controllers\UpController->actionIndex()
#42 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#43 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#44 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction()
#45 /var/www/html/vendor/craftcms/cms/src/console/ControllerTrait.php(88): yii\console\Controller->runAction()
#46 /var/www/html/vendor/craftcms/cms/src/console/Controller.php(216): craft\console\Controller->traitRunAction()
#47 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): craft\console\Controller->runAction()
#48 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction()
#49 /var/www/html/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction()
#50 /var/www/html/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction()
#51 /var/www/html/vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest()
#52 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest()
#53 /var/www/html/craft(12): yii\base\Application->run()
#54 {main}

This is the same branch in which we encountered issue #16150, so it's possible my database got somehow messed up at that point.

Craft CMS version

5.5.2

PHP version

8.3

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@MoritzLost MoritzLost added the bug label Nov 22, 2024
@brandonkelly
Copy link
Member

Any chance you can share your database (before applying the project config), Composer files, and the incoming project config data with us? ([email protected])

@MoritzLost
Copy link
Contributor Author

@brandonkelly Done! Hope this helps, let me know if you need anything else.

@MoritzLost
Copy link
Contributor Author

As per the discussion with Oli via e-mail, this was likely a one-off problem caused by an earlier issue with the project config. I'm closing this for now, I'll report back in case we encounter this again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants