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

Migration fails on Craft 3.4.9 #5749

Closed
justinholtweb opened this issue Mar 3, 2020 · 2 comments
Closed

Migration fails on Craft 3.4.9 #5749

justinholtweb opened this issue Mar 3, 2020 · 2 comments

Comments

@justinholtweb
Copy link

justinholtweb commented Mar 3, 2020

Description

After a composer update, a migration occurs which fails on Craft 3.4.9 with the errors:

One of Craft CMS’s migrations failed.

Database Exception: SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'craft_plugins_handle_unq_idx'
The SQL being executed was: ALTER TABLE craft_plugins ADD UNIQUE INDEX craft_plugins_handle_unq_idx (handle)

Migration: craft\migrations\m150403_184247_plugins_table_changes

Output:

> create unique index craft_plugins_handle_unq_idx on {{%plugins}} (handle) ...Exception: SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'craft_plugins_handle_unq_idx'
The SQL being executed was: ALTER TABLE craft_plugins ADD UNIQUE INDEX craft_plugins_handle_unq_idx (handle) (/Users/jholt/Sites/hytera-craft3/vendor/yiisoft/yii2/db/Schema.php:674)
#0 /Users/jholt/Sites/hytera-craft3/vendor/yiisoft/yii2/db/Command.php(1295): yii\db\Schema->convertException(Object(PDOException), 'ALTER TABLE cr...')
#1 /Users/jholt/Sites/hytera-craft3/vendor/yiisoft/yii2/db/Command.php(1091): yii\db\Command->internalExecute('ALTER TABLE cr...')
#2 /Users/jholt/Sites/hytera-craft3/vendor/yiisoft/yii2/db/Migration.php(495): yii\db\Command->execute()
#3 /Users/jholt/Sites/hytera-craft3/vendor/craftcms/cms/src/db/Migration.php(385): yii\db\Migration->createIndex('craft_plugins_h...', '{{%plugins}}', Array, true)
#4 /Users/jholt/Sites/hytera-craft3/vendor/craftcms/cms/src/migrations/m150403_184247_plugins_table_changes.php(40): craft\db\Migration->createIndex('craft_plugins_h...', '{{%plugins}}', Array, true)
#5 /Users/jholt/Sites/hytera-craft3/vendor/craftcms/cms/src/db/Migration.php(52): craft\migrations\m150403_184247_plugins_table_changes->safeUp()
#6 /Users/jholt/Sites/hytera-craft3/vendor/craftcms/cms/src/db/MigrationManager.php(233): craft\db\Migration->up(true)
#7 /Users/jholt/Sites/hytera-craft3/vendor/craftcms/cms/src/db/MigrationManager.php(153): craft\db\MigrationManager->migrateUp(Object(craft\migrations\m150403_184247_plugins_table_changes))
#8 /Users/jholt/Sites/hytera-craft3/vendor/craftcms/cms/src/services/Updates.php(225): craft\db\MigrationManager->up()
#9 /Users/jholt/Sites/hytera-craft3/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(510): craft\services\Updates->runMigrations(Array)
#10 /Users/jholt/Sites/hytera-craft3/vendor/craftcms/cms/src/controllers/UpdaterController.php(203): craft\controllers\BaseUpdaterController->runMigrations(Array, 'restore-db')
#11 [internal function]: craft\controllers\UpdaterController->actionMigrate()
#12 /Users/jholt/Sites/hytera-craft3/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#13 /Users/jholt/Sites/hytera-craft3/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#14 /Users/jholt/Sites/hytera-craft3/vendor/craftcms/cms/src/web/Controller.php(178): yii\base\Controller->runAction('migrate', Array)
#15 /Users/jholt/Sites/hytera-craft3/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('migrate', Array)
#16 /Users/jholt/Sites/hytera-craft3/vendor/craftcms/cms/src/web/Application.php(291): yii\base\Module->runAction('updater/migrate', Array)
#17 /Users/jholt/Sites/hytera-craft3/vendor/craftcms/cms/src/web/Application.php(646): craft\web\Application->runAction('updater/migrate')
#18 /Users/jholt/Sites/hytera-craft3/vendor/craftcms/cms/src/web/Application.php(223): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))
#19 /Users/jholt/Sites/hytera-craft3/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#20 /Users/jholt/Sites/hytera-craft3/web/index.php(21): yii\base\Application->run()
#21 {main}

Additional info

  • Craft version: 3.4.9
  • PHP version: 7.1
@justinholtweb
Copy link
Author

I got this resolved by rolling back Craft to 3.4.5. I think what happened is the update to 3.4.9 did not fully complete therefore some tables were missing from the DB causing subsequent migrations to fail.

@bkmorse
Copy link

bkmorse commented Apr 5, 2020

I was running into the same issue, what worked for me was running the composer command in the container (as I am using docker locally). Then setting backupOnUpdate in general.php to false.

I saw an error in the log: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known when I did the composer command (not in the container), so I thought it was trying to access the database, so I ran the composer command in the docker container and it ran without giving me that error. I think after 3.4.5 there is some db connection the command runs when updating craft cms.

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

No branches or pull requests

2 participants