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

[4.x]: Migration error with universal_users #12062

Closed
paul-frost opened this issue Oct 5, 2022 · 3 comments
Closed

[4.x]: Migration error with universal_users #12062

paul-frost opened this issue Oct 5, 2022 · 3 comments

Comments

@paul-frost
Copy link

paul-frost commented Oct 5, 2022

What happened?

Description

Updating from 3.7.55.3 to 4.2.5.1, everything going OK until.
Run craft migrate/all and it fails with "failed to apply m210817_014201_universal_users". See below:

*** applying m210817_014201_universal_users
    > alter column username in table {{%users}} to string ... done (time: 0.009s)
    > alter column email in table {{%users}} to string ... done (time: 0.008s)
    > alter column firstName in table {{%users}} to string ... done (time: 0.010s)
    > alter column lastName in table {{%users}} to string ... done (time: 0.011s)
    > add column active boolean NOT NULL DEFAULT FALSE AFTER `admin` to table {{%users}} ...Exception: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'active'
The SQL being executed was: ALTER TABLE `users` ADD `active` tinyint(1) NOT NULL DEFAULT FALSE AFTER `admin` (/home/pfwebco/dfok/craft/vendor/yiisoft/yii2/db/Schema.php:676)
#0 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema->convertException(Object(PDOException), 'ALTER TABLE `us...')
#1 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/db/Command.php(1102): yii\db\Command->internalExecute('ALTER TABLE `us...')
#2 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/db/Migration.php(377): yii\db\Command->execute()
#3 /home/pfwebco/dfok/craft/vendor/craftcms/cms/src/migrations/m210817_014201_universal_users.php(34): yii\db\Migration->addColumn('{{%users}}', 'active', Object(craft\db\mysql\ColumnSchemaBuilder))
#4 /home/pfwebco/dfok/craft/vendor/craftcms/cms/src/db/Migration.php(49): craft\migrations\m210817_014201_universal_users->safeUp()
#5 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
#6 /home/pfwebco/dfok/craft/vendor/craftcms/cms/src/console/controllers/MigrateController.php(360): yii\console\controllers\BaseMigrateController->migrateUp('m210817_014201_...')
#7 [internal function]: craft\console\controllers\MigrateController->actionAll()
#8 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#9 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#10 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/console/Controller.php(182): yii\base\Controller->runAction('all', Array)
#11 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/base/Module.php(552): yii\console\Controller->runAction('all', Array)
#12 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#13 /home/pfwebco/dfok/craft/vendor/craftcms/cms/src/console/Application.php(90): yii\console\Application->runAction('migrate/all', Array)
#14 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('migrate/all', Array)
#15 /home/pfwebco/dfok/craft/vendor/craftcms/cms/src/console/Application.php(121): yii\console\Application->handleRequest(Object(craft\console\Request))
#16 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#17 /home/pfwebco/dfok/craft/craft(13): yii\base\Application->run()
#18 {main}
*** failed to apply m210817_014201_universal_users (time: 0.043s)

Steps to reproduce

  1. I tried deleting all the other users from the users table except the admin one and tried again, same result.

Expected behavior

Actual behavior

*** failed to apply m210817_014201_universal_users (time: 0.043s)

Craft CMS version

4.2.5.1

PHP version

8.1.10

Operating system and version

Mac OS 12.6

Database type and version

MySQL 5.7.39 but I get a green tick in the system report

Image driver and version

GD 8.1.10

Installed plugins and versions

"besteadfast/craft-preparse-field": "^2.0",
"craftcms/cms": "^4.0.0",
"craftcms/contact-form": "^3.0",
"craftcms/contact-form-honeypot": "^2.0",
"craftcms/feed-me": "^5.0",
"craftcms/redactor": "^3.0",
"ether/simplemap": "^4.0",
"hillholliday/craft-user-manual": "^4.0",
"matt-west/craft-recaptcha": "^2.0",
"verbb/image-resizer": "^3.0",
"vlucas/phpdotenv": "^5.4.0"

@paul-frost
Copy link
Author

paul-frost commented Oct 5, 2022

I have tried this again completely from scratch, twice, and both times got a slightly different error to above but the same result:

*** applying m210817_014201_universal_users
    > alter column username in table {{%users}} to string ... done (time: 0.198s)
    > alter column email in table {{%users}} to string ... done (time: 0.191s)
    > alter column firstName in table {{%users}} to string ... done (time: 0.016s)
    > alter column lastName in table {{%users}} to string ... done (time: 0.016s)
    > add column active boolean NOT NULL DEFAULT FALSE AFTER `admin` to table {{%users}} ... done (time: 0.181s)
    > create index idx_gnuumuhxwowhiyrrficgovhegblxsxfgpqld on {{%users}} (active) ... done (time: 0.069s)
    > create index idx_ymmzxtusqnnvqmxiiprudqccxbtkiqphwgun on {{%users}} (locked) ... done (time: 0.063s)
    > create index idx_fqedcftavybdposznoypljblazcmlghvchiz on {{%users}} (pending) ... done (time: 0.059s)
    > create index idx_fouxgkcoctougrpdmhuyxkxngufhuwknuldz on {{%users}} (suspended) ... done (time: 0.087s)
    > update in {{%users}} ... done (time: 0.018s)
    > update in {{%users}} ... done (time: 0.001s)
Exception: Changes to the project config are not possible while in read-only mode. (/home/pfwebco/dfok/craft/vendor/craftcms/cms/src/services/ProjectConfig.php:503)
#0 /home/pfwebco/dfok/craft/vendor/craftcms/cms/src/services/ProjectConfig.php(475): craft\services\ProjectConfig->_setInternal('users', Array, NULL, true, false)
#1 /home/pfwebco/dfok/craft/vendor/craftcms/cms/src/migrations/m210817_014201_universal_users.php(67): craft\services\ProjectConfig->set('users', Array)
#2 /home/pfwebco/dfok/craft/vendor/craftcms/cms/src/db/Migration.php(49): craft\migrations\m210817_014201_universal_users->safeUp()
#3 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
#4 /home/pfwebco/dfok/craft/vendor/craftcms/cms/src/console/controllers/MigrateController.php(360): yii\console\controllers\BaseMigrateController->migrateUp('m210817_014201_...')
#5 [internal function]: craft\console\controllers\MigrateController->actionAll()
#6 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#7 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#8 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/console/Controller.php(182): yii\base\Controller->runAction('all', Array)
#9 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/base/Module.php(552): yii\console\Controller->runAction('all', Array)
#10 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#11 /home/pfwebco/dfok/craft/vendor/craftcms/cms/src/console/Application.php(90): yii\console\Application->runAction('migrate/all', Array)
#12 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('migrate/all', Array)
#13 /home/pfwebco/dfok/craft/vendor/craftcms/cms/src/console/Application.php(121): yii\console\Application->handleRequest(Object(craft\console\Request))
#14 /home/pfwebco/dfok/craft/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#15 /home/pfwebco/dfok/craft/craft(13): yii\base\Application->run()
#16 {main}
*** failed to apply m210817_014201_universal_users (time: 0.982s)

I have checked the permissions of the vendor folder and contents and all the others and they are set to 755, which is what the hosting company specify.

@paul-frost
Copy link
Author

I have now resolved this issue and it wasn't a bug, but my incompetence.
I had a line in my config/general.php that was preventing the update.
'allowAdminChanges' => $isProd,
I removed that it it worked.

@brandonkelly
Copy link
Member

Glad you got it sorted!

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

No branches or pull requests

2 participants