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

Upgrade to 3.2.0 fails during migration #4530

Closed
RyanRoberts opened this issue Jul 11, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@RyanRoberts
Copy link

commented Jul 11, 2019

Description

I'm upgrading an install to 3.2 but it falls over at "migrate/all".

Steps to reproduce

  1. run ./craft update craft
  2. get error

Additional info

  • Craft version: 3.1.34 => 3.2.0
  • PHP version: 7.3.6
  • Database driver & version: MySQL 5.7.26
  • Plugins & versions: here's a screenshot

I've not had any luck finding a way around it. Here's the cli output which is a mystery to me:

Applying new migrations ... error: The command "'/project/craft' 'migrate/all' '--no-content'" failed.

Exit Code: 1(General error)

Working directory: /project

Output:
================
Yii Migration Tool (based on Yii v2.0.21)

    > create table {{%drafts}} ...Exception: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'drafts' already exists
The SQL being executed was: CREATE TABLE `drafts` (
	`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
	`sourceId` int(11) NOT NULL,
	`revisionId` int(11) NOT NULL,
	`creatorId` int(11) NOT NULL,
	`name` varchar(255) NOT NULL,
	`notes` text
) ENGINE=InnoDb DEFAULT CHARSET=utf8 (/project/vendor/yiisoft/yii2/db/Schema.php:664)
#0 /project/vendor/yiisoft/yii2/db/Command.php(1295): yii\db\Schema->convertException(Object(PDOException), 'CREATE TABLE `d...')
#1 /project/vendor/yiisoft/yii2/db/Command.php(1091): yii\db\Command->internalExecute('CREATE TABLE `d...')
#2 /project/vendor/yiisoft/yii2/db/Migration.php(323): yii\db\Command->execute()
#3 /project/vendor/craftcms/cms/src/migrations/m190312_152740_element_revisions.php(27): yii\db\Migration->createTable('{{%drafts}}', Array)
#4 /project/vendor/craftcms/cms/src/db/Migration.php(56): craft\migrations\m190312_152740_element_revisions->safeUp()
#5 /project/vendor/craftcms/cms/src/db/MigrationManager.php(243): craft\db\Migration->up(true)
#6 /project/vendor/craftcms/cms/src/db/MigrationManager.php(163): craft\db\MigrationManager->migrateUp(Object(craft\migrations\m190312_152740_element_revisions))
#7 /project/vendor/craftcms/cms/src/services/Updates.php(217): craft\db\MigrationManager->up()
#8 /project/vendor/craftcms/cms/src/console/controllers/MigrateController.php(259): craft\services\Updates->runMigrations(Array)
#9 [internal function]: craft\console\controllers\MigrateController->actionAll()
#10 /project/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#11 /project/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#12 /project/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('all', Array)
#13 /project/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('all', Array)
#14 /project/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#15 /project/vendor/craftcms/cms/src/console/Application.php(93): yii\console\Application->runAction('migrate/all', Array)
#16 /project/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('migrate/all', Array)
#17 /project/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#18 /project/craft(22): yii\base\Application->run()
#19 {main}


Error Output:
================
Exception 'craft\errors\MigrateException' with message 'An error occurred while migrating Craft CMS.'

in /project/vendor/craftcms/cms/src/services/Updates.php:233

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


Output:

Yii Migration Tool (based on Yii v2.0.21)

    > create table {{%drafts}} ...Exception: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'drafts' already exists
The SQL being executed was: CREATE TABLE `drafts` (
	`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
	`sourceId` int(11) NOT NULL,
	`revisionId` int(11) NOT NULL,
	`creatorId` int(11) NOT NULL,
	`name` varchar(255) NOT NULL,
	`notes` text
) ENGINE=InnoDb DEFAULT CHARSET=utf8 (/project/vendor/yiisoft/yii2/db/Schema.php:664)
#0 /project/vendor/yiisoft/yii2/db/Command.php(1295): yii\db\Schema->convertException(Object(PDOException), 'CREATE TABLE `d...')
#1 /project/vendor/yiisoft/yii2/db/Command.php(1091): yii\db\Command->internalExecute('CREATE TABLE `d...')
#2 /project/vendor/yiisoft/yii2/db/Migration.php(323): yii\db\Command->execute()
#3 /project/vendor/craftcms/cms/src/migrations/m190312_152740_element_revisions.php(27): yii\db\Migration->createTable('{{%drafts}}', Array)
#4 /project/vendor/craftcms/cms/src/db/Migration.php(56): craft\migrations\m190312_152740_element_revisions->safeUp()
#5 /project/vendor/craftcms/cms/src/db/MigrationManager.php(243): craft\db\Migration->up(true)
#6 /project/vendor/craftcms/cms/src/db/MigrationManager.php(163): craft\db\MigrationManager->migrateUp(Object(craft\migrations\m190312_152740_element_revisions))
#7 /project/vendor/craftcms/cms/src/services/Updates.php(217): craft\db\MigrationManager->up()
#8 /project/vendor/craftcms/cms/src/console/controllers/MigrateController.php(259): craft\services\Updates->runMigrations(Array)
#9 [internal function]: craft\console\controllers\MigrateController->actionAll()
#10 /project/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#11 /project/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#12 /project/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('all', Array)
#13 /project/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('all', Array)
#14 /project/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#15 /project/vendor/craftcms/cms/src/console/Application.php(93): yii\console\Application->runAction('migrate/all', Array)
#16 /project/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('migrate/all', Array)
#17 /project/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#18 /project/craft(22): yii\base\Application->run()
#19 {main}
@brandonkelly

This comment has been minimized.

Copy link
Member

commented Jul 11, 2019

The error you posted would happen if you were trying to update to Craft 3.2 on top of a database that had already been partially updated to Craft 3.2. Perhaps after it failed the first time, you restored a database backup and tried again; but restoring a database backup won’t delete any new tables that were added by the initial update attempt.

Try doing this to ensure you’re really starting fresh:

  1. Delete your database
  2. Recreate it
  3. Import your database backup
  4. Delete your config/project.yaml file (if you have one)
  5. Delete your storage/logs/ folder
  6. Reattempt the update

If it fails again, this time your storage/logs/ folder should contain the original error. Please post that, and its stack trace.

@RyanRoberts

This comment has been minimized.

Copy link
Author

commented Jul 12, 2019

👍 Thanks, that does make sense. I'll give it a go tomorrow morning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.