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 Error when updating from 3.4.27 to 3.5.2 #6593

Closed
JansonChe opened this issue Aug 9, 2020 · 8 comments
Closed

Migration Error when updating from 3.4.27 to 3.5.2 #6593

JansonChe opened this issue Aug 9, 2020 · 8 comments
Labels

Comments

@JansonChe
Copy link

JansonChe commented Aug 9, 2020

Description

Hi there

Based on @brandonkelly's update, I've tried to update from 3.4.27 to 3.5.2 and received a similar exception.

Thanks a lot for your help.

The SQL being executed was: ALTER TABLE plugins ADD licensedEdition varchar(255) AFTER licenseKeyStatus

Migration: craft\migrations\m190104_152725_store_licensed_plugin_editions

Output:

> add column licensedEdition string AFTER licenseKeyStatus to table {{%plugins}} ...Exception: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'licensedEdition'
The SQL being executed was: ALTER TABLE plugins ADD licensedEdition varchar(255) AFTER licenseKeyStatus (/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 pl...')
#1 /app/vendor/yiisoft/yii2/db/Command.php(1093): yii\db\Command->internalExecute('ALTER TABLE pl...')
#2 /app/vendor/yiisoft/yii2/db/Migration.php(377): yii\db\Command->execute()
#3 /app/vendor/craftcms/cms/src/migrations/m190104_152725_store_licensed_plugin_editions.php(18): yii\db\Migration->addColumn('{{%plugins}}', 'licensedEdition', Object(craft\db\mysql\ColumnSchemaBuilder))
#4 /app/vendor/craftcms/cms/src/db/Migration.php(52): craft\migrations\m190104_152725_store_licensed_plugin_editions->safeUp()
#5 /app/vendor/craftcms/cms/src/db/MigrationManager.php(232): craft\db\Migration->up(true)
#6 /app/vendor/craftcms/cms/src/db/MigrationManager.php(148): craft\db\MigrationManager->migrateUp(Object(craft\migrations\m190104_152725_store_licensed_plugin_editions))
#7 /app/vendor/craftcms/cms/src/services/Updates.php(220): craft\db\MigrationManager->up()
#8 /app/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(509): craft\services\Updates->runMigrations(Array)
#9 /app/vendor/craftcms/cms/src/controllers/UpdaterController.php(203): craft\controllers\BaseUpdaterController->runMigrations(Array, 'restore-db')
#10 [internal function]: craft\controllers\UpdaterController->actionMigrate()
#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/craftcms/cms/src/web/Controller.php(181): yii\base\Controller->runAction('migrate', Array)
#14 /app/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('migrate', Array)
#15 /app/vendor/craftcms/cms/src/web/Application.php(294): yii\base\Module->runAction('updater/migrate', Array)
#16 /app/vendor/craftcms/cms/src/web/Application.php(684): craft\web\Application->runAction('updater/migrate')
#17 /app/vendor/craftcms/cms/src/web/Application.php(227): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))
#18 /app/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#19 /app/web/index.php(21): yii\base\Application->run()
#20 {main}

Steps to reproduce

  1. Update from 3.4.27 to 3.5.2 (via Control Panel)
  2. Get migration error above

Additional info

  • Craft version: 3.5.2
  • PHP version: 7.3.9
  • Database driver & version: 5.7.26
  • Plugins & versions:
    "born05/craft-assetusage": "2.1.0",
    "craftcms/redactor": "2.6.1",
    "doublesecretagency/craft-cpcss": "2.2.1",
    "ether/seo": "^3.6",
    "mmikkel/cp-field-inspect": "1.1.3",
    "sebastianlenz/linkfield": "^2.0-beta",
    "verbb/super-table": "2.5.2",
@JansonChe JansonChe added the bug label Aug 9, 2020
@brandonkelly
Copy link
Member

@JansonChe sounds like you didn't restore a database backup before re-attempting the update.

@JansonChe
Copy link
Author

@brandonkelly I restored the database backup after the failed attempt and tried to re-run the update again, but it keeps running into the same exception. I also tried running the update using ./craft update craft and also setting up a second database and importing the backup of a working 3.4.27 environment, but still the same issue.

It's the first time I'm having this kind of issues with updating a craft project.
Is there anything that I should check before running the update?
Am I missing something? Do you have a hint on what I could try?

Thanks a lot for your help!

@JansonChe
Copy link
Author

@brandonkelly Using an empty database, running ./craft setup and then updating seems to work. But all the content would be gone, which makes this very much the last resort...

@brandonkelly
Copy link
Member

@JansonChe The migration you are getting that error on was added in Craft 3.1. It should not be getting run a second time during the 3.5 update.

Craft keeps track of the migrations it has run using the migrations table. Maybe you cleared out the contents of that table at some point?

@JansonChe
Copy link
Author

@brandonkelly Oh ok, that's weird... I can't recall doing anything like that, but maybe there was an error once while updating or something...

Either way... I need to find a way to get the updates working again without loosing the websites content....
Is there something I can do to get the updates working again without loosing call the content that is already in the database?

Thanks a lot!

@brandonkelly
Copy link
Member

No migration error would end up removing rows in the migrations table. You should really try to figure out how those rows went missing before worrying about updating to 3.5 – if it was a bad DB backup/restore or something, then other data could have been effected too. Maybe import some recent DB backups and try to figure out at what point the table lost its data.

Ideally, you will restore a migrations table backup from before the data went missing, so you don’t have to manually reenter the missing data.

If you can’t do that, then you will need to manually add the missing rows. You can find a list of all the migrations that should be listed by looking at https://github.com/craftcms/cms/tree/3.4.27/src/migrations. For any migrations that are missing from the table, add a new row, and set the type column to app. If you have any plugins installed, you will need to check their migrations as well, based on the plugin versions you have installed.

@brandonkelly
Copy link
Member

Going to close this since this isn’t a Craft bug. If you need additional help, please write into [email protected] and link to this issue for context, and we can try to help further from there.

@JansonChe
Copy link
Author

@brandonkelly I'll look if I can figure out what went wrong based on your input. Thanks a lot for your help!

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