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

Integrity constraint violation when updating from 3.4.22.1 to 3.5.1 #6580

Closed
elfacht opened this issue Aug 7, 2020 · 2 comments
Closed

Integrity constraint violation when updating from 3.4.22.1 to 3.5.1 #6580

elfacht opened this issue Aug 7, 2020 · 2 comments
Labels

Comments

@elfacht
Copy link

elfacht commented Aug 7, 2020

Description

Running ./craft migrate/all after updating to 3.5.1 causes this exception:

 > create unique index bnb_migrations_track_name_unq_idx on {{%migrations}} (track,name) ...Exception: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'content-m181105_123532_migration_places' for key 'bnb_migrations_track_name_unq_idx'
The SQL being executed was: ALTER TABLE `bnb_migrations` ADD UNIQUE INDEX `bnb_migrations_track_name_unq_idx` (`track`, `name`) (/app/vendor/yiisoft/yii2/db/Schema.php:677)
#0 /app/vendor/yiisoft/yii2/db/Command.php(1298): yii\db\Schema->convertException(Object(PDOException), 'ALTER TABLE `bn...')
#1 /app/vendor/yiisoft/yii2/db/Command.php(1093): yii\db\Command->internalExecute('ALTER TABLE `bn...')
#2 /app/vendor/yiisoft/yii2/db/Migration.php(495): yii\db\Command->execute()
#3 /app/vendor/craftcms/cms/src/db/Migration.php(385): yii\db\Migration->createIndex('bnb_migrations_...', '{{%migrations}}', Array, true)
#4 /app/vendor/craftcms/cms/src/migrations/m200606_231117_migration_tracks.php(56): craft\db\Migration->createIndex('bnb_migrations_...', '{{%migrations}}', Array, true)
#5 /app/vendor/craftcms/cms/src/db/Migration.php(52): craft\migrations\m200606_231117_migration_tracks->safeUp()
#6 /app/vendor/craftcms/cms/src/db/MigrationManager.php(228): craft\db\Migration->up(true)
#7 /app/vendor/craftcms/cms/src/db/MigrationManager.php(148): craft\db\MigrationManager->migrateUp(Object(craft\migrations\m200606_231117_migration_tracks))
#8 /app/vendor/craftcms/cms/src/services/Updates.php(220): craft\db\MigrationManager->up()
#9 /app/vendor/craftcms/cms/src/console/controllers/MigrateController.php(328): craft\services\Updates->runMigrations(Array)
#10 [internal function]: craft\console\controllers\MigrateController->actionAll()
#11 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12  /app/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#13 /app/vendor/yiisoft/yii2/console/Controller.php(181): yii\base\Controller->runAction('all', Array)
#14 /app/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('all', Array)
#15 /app/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#16 /app/vendor/craftcms/cms/src/console/Application.php(87): yii\console\Application->runAction('migrate/all', Array)
#17 /app/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('migrate/all', Array)
#18 /app/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#19 /app/craft(22): yii\base\Application->run()
#20 {main}
Exception 'craft\errors\MigrateException' with message 'An error occurred while migrating Craft CMS.'

in /app/vendor/craftcms/cms/src/services/Updates.php:235

Stack trace:
#0 /app/vendor/craftcms/cms/src/console/controllers/MigrateController.php(328): craft\services\Updates->runMigrations(Array)
#1 [internal function]: craft\console\controllers\MigrateController->actionAll()
#2 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#3 /app/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#4 /app/vendor/yiisoft/yii2/console/Controller.php(181): yii\base\Controller->runAction('all', Array)
#5 /app/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('all', Array)
#6 /app/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#7 /app/vendor/craftcms/cms/src/console/Application.php(87): yii\console\Application->runAction('migrate/all', Array)
#8 /app/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('migrate/all', Array)
#9 /app/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#10 /app/craft(22): yii\base\Application->run()
#11 {main}

Steps to reproduce

  1. Run Update from 3.4.22.1
  2. Run ./craft migrate/all

Additional info

  • Craft version: 3.5.1
  • PHP version: 7.3.8
  • Database driver & version: MySQL 5.7.26
  • Plugins & versions: Super Table, Redactor, CP Field Inspect, Simplemap, Craft Cookies, SEO, Craft Minify, Field Manager
@brandonkelly
Copy link
Member

Thanks for reporting that! Just fixed for the next release.

If you want to get the fix early, change your craftcms/cms requirement in composer.json to:

"require": {
  "craftcms/cms": "dev-develop",
  "...": "..."
}

Then run composer update.

Then restore a DB backup from before attempting to update to 3.5, and try the update again.

@brandonkelly
Copy link
Member

Craft 3.5.2 is out now with this fix. Again, remember to restore a DB backup before reattempting the update.

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