craftcms / craftcms/cms

[3.x]: Unable to apply migrations: Unknown column 'pluginId' in 'migrations'

Open
#11,087 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug craft3
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

What happened?
Description

Whenever trying to perform php craft migrate/all on one of my projects, the following errors are output in the terminal:

*** applying m150403_183908_migrations_table_changes
    > add column type enum('app','plugin','content') NOT NULL DEFAULT 'app' AFTER `pluginId` to table {{%migrations}} ...Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pluginId' in 'migrations'
The SQL being executed was: ALTER TABLE `migrations` ADD `type` enum('app','plugin','content') NOT NULL DEFAULT 'app' AFTER `pluginId` (/var/www/html/vendor/yiisoft/yii2/db/Schema.php:678)
#0 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema->convertException(Object(PDOException), 'ALTER TABLE `mi...')
#1 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1102): yii\db\Command->internalExecute('ALTER TABLE `mi...')
#2 /var/www/html/vendor/yiisoft/yii2/db/Migration.php(377): yii\db\Command->execute()
#3 /var/www/html/vendor/craftcms/cms/src/migrations/m150403_183908_migrations_table_changes.php(25): yii\db\Migration->addColumn('{{%migrations}}', 'type', Object(craft\db\mysql\ColumnSchemaBuilder))
#4 /var/www/html/vendor/craftcms/cms/src/db/Migration.php(52): craft\migrations\m150403_183908_migrations_table_changes->safeUp()
#5 /var/www/html/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
#6 /var/www/html/vendor/craftcms/cms/src/console/controllers/MigrateController.php(386): yii\console\controllers\BaseMigrateController->migrateUp('m150403_183908_...')
#7 [internal function]: craft\console\controllers\MigrateController->actionAll()
#8 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#9 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#10 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(184): yii\base\Controller->runAction('all', Array)
#11 /var/www/html/vendor/yiisoft/yii2/base/Module.php(534): yii\console\Controller->runAction('all', Array)
#12 /var/www/html/vendor/yiisoft/yii2/console/Application.php(181): yii\base\Module->runAction('migrate/all', Array)
#13 /var/www/html/vendor/craftcms/cms/src/console/Application.php(89): yii\console\Application->runAction('migrate/all', Array)
#14 /var/www/html/vendor/yiisoft/yii2/console/Application.php(148): craft\console\Application->runAction('migrate/all', Array)
#15 /var/www/html/vendor/yiisoft/yii2/base/Application.php(392): yii\console\Application->handleRequest(Object(craft\console\Request))
#16 /var/www/html/craft(23): yii\base\Application->run()
#17 {main}
*** failed to apply m150403_183908_migrations_table_changes (time: 0.016s)

Looking at the database's migrations table, there is no such pluginId column. My other Craft projects (that successfully migrate) don't have this column either (their migrations table structure looks the same as this failing project).

Steps to reproduce
  1. php craft migrate/all
Expected behavior

Successfully apply pending migrations.

Actual behavior

Running php craft migrate/all fails and migrations remain unapplied.

Additional info

I've sent the complete project archive + DB backup to support@craftcms.com on Apr 21, 2022 if that makes it easier to debug.

Craft CMS version

3.7.26

PHP version

8.0.16

Operating system and version

Ubuntu 20.04.4 LTS

Database type and version

MySQL 8.0.27

Image driver and version

Imagick 3.6.0 (ImageMagick 6.9.10-23)

Installed plugins and versions
"craftcms/ckeditor": "^1.1",
"craftcms/cms": "^3.7",
"craftcms/feed-me": "^4.4",
"craftcms/postmark": "^2.1",
"craftcms/redactor": "^2.10",
"doublesecretagency/craft-inventory": "^2.1",
"ether/tags": "^1.0",
"mmikkel/retcon": "^2.2",
"nystudio107/craft-imageoptimize": "^1.6.33",
"nystudio107/craft-minify": "^1.2",
"nystudio107/craft-retour": "^3.1",
"nystudio107/craft-seomatic": "^3.3.32",
"nystudio107/craft-vite": "^1.0",
"pennebaker/craft-architect": "^2.4",
"putyourlightson/craft-blitz": "^3.10",
"sebastianlenz/linkfield": "^2.0.0@beta",
"vaersaagod/dospaces": "^1.1",
"verbb/formie": "^1.4",
"verbb/navigation": "^1.4.13",
"verbb/super-table": "^2.6.7",
"vlucas/phpdotenv": "^3.4.0",
"yiisoft/yii2-redis": "^2.0.6"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with vendor/craftcms/cms/src/migrations/m150403_183908_migrations_table_changes.php and compare its ALTER TABLE statement with the failing migrations table schema. Reproduce with php craft migrate/all against the reported Craft 3.7.26, PHP 8.0.16, and MySQL 8.0.27 setup. Done means pending migrations apply without the unknown pluginId column error.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, php
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.