craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.22k stars 626 forks source link

Migration error: failed to apply m210624_222934_drop_deprecated_tables #14098

Closed 0xElectric closed 8 months ago

0xElectric commented 8 months ago

What happened?

Description

Migration error on upgrade to craft 4 Followed the instructions in https://craftcms.com/docs/4.x/upgrade.html I have confirmed entrydrafts and entryversions does not exist deprecated tables that exists are: templatecacheelements, templatecachequeries, templatecaches Everything went well until step 9 php craft migrate/all

...
*** applying m210624_222934_drop_deprecated_tables
    > dropping all foreign keys to {{%templatecacheelements}} ...Exception: Attempt to read property "enabled" on null (/var/www/html/vendor/yiisoft/yii2/log/Dispatcher.php:190)
#0 /var/www/html/vendor/yiisoft/yii2/log/Dispatcher.php(190): yii\base\ErrorHandler->handleError(2, 'Attempt to read...', '/var/www/html/v...', 190)
#1 /var/www/html/vendor/yiisoft/yii2/log/Logger.php(226): yii\log\Dispatcher->dispatch(Array, false)
#2 /var/www/html/vendor/yiisoft/yii2/log/Logger.php(181): yii\log\Logger->flush()
#3 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(482): yii\log\Logger->log('SHOW FULL COLUM...', 80, 'yii\\db\\Command:...')
#4 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1166): yii\BaseYii::beginProfile('SHOW FULL COLUM...', 'yii\\db\\Command:...')
#5 /var/www/html/vendor/yiisoft/yii2/db/Command.php(410): yii\db\Command->queryInternal('fetchAll', NULL)
#6 /var/www/html/vendor/yiisoft/yii2/db/mysql/Schema.php(328): yii\db\Command->queryAll()
#7 /var/www/html/vendor/craftcms/cms/src/db/mysql/Schema.php(294): yii\db\mysql\Schema->findColumns(Object(craft\db\TableSchema))
#8 /var/www/html/vendor/yiisoft/yii2/db/Schema.php(756): craft\db\mysql\Schema->loadTableSchema('queue')
#9 /var/www/html/vendor/yiisoft/yii2/db/Schema.php(192): yii\db\Schema->getTableMetadata('queue', 'schema', false)
#10 /var/www/html/vendor/yiisoft/yii2/db/Schema.php(782): yii\db\Schema->getTableSchema('queue', false)
#11 /var/www/html/vendor/yiisoft/yii2/db/Schema.php(205): yii\db\Schema->getSchemaMetadata('', 'schema', false)
#12 /var/www/html/vendor/craftcms/cms/src/helpers/Db.php(1271): yii\db\Schema->getTableSchemas()
#13 /var/www/html/vendor/craftcms/cms/src/db/Migration.php(379): craft\helpers\Db::dropAllForeignKeysToTable('{{%templatecach...', Object(craft\db\Connection))
#14 /var/www/html/vendor/craftcms/cms/src/migrations/m210624_222934_drop_deprecated_tables.php(31): craft\db\Migration->dropAllForeignKeysToTable('{{%templatecach...')
#15 /var/www/html/vendor/craftcms/cms/src/db/Migration.php(49): craft\migrations\m210624_222934_drop_deprecated_tables->safeUp()
#16 /var/www/html/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
#17 /var/www/html/vendor/craftcms/cms/src/console/controllers/MigrateController.php(361): yii\console\controllers\BaseMigrateController->migrateUp('m210624_222934_...')
#18 [internal function]: craft\console\controllers\MigrateController->actionAll()
#19 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#20 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#21 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('all', Array)
#22 /var/www/html/vendor/craftcms/cms/src/console/ControllerTrait.php(90): yii\console\Controller->runAction('all', Array)
#23 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): craft\console\controllers\MigrateController->runAction('all', Array)
#24 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#25 /var/www/html/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction('migrate/all', Array)
#26 /var/www/html/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('migrate/all', Array)
#27 /var/www/html/vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest(Object(craft\console\Request))
#28 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#29 /var/www/html/craft(13): yii\base\Application->run()
#30 {main}
*** failed to apply m210624_222934_drop_deprecated_tables (time: 0.074s)

1 from 45 migration was applied.

Migration failed. The rest of the migrations are canceled.

Steps to reproduce

  1. Upgrade to latest craft 3 version (3.9.10 at time of writing)
  2. Follow upgrade guide (https://craftcms.com/docs/4.x/upgrade.html)
  3. Until step 9 craft migrate/all (where the error occurs)

Expected behavior

Successful migration

Actual behavior

failed to apply m210624_222934_drop_deprecated_tables Migration failed. The rest of the migrations are canceled.

Craft CMS version

3.9.10 => ^4.0.0

PHP version

8.1.26

Operating system and version

Ubuntu 22.04.2 LTS

Database type and version

mysql Ver 15.1 Distrib 10.5.21-MariaDB, for debian-linux-gnu (x86_64)

Image driver and version

No response

Installed plugins and versions

"craftcms/aws-s3": "1.3.2", "craftcms/redactor": "2.10.12", "diginov/craft-sentry-logger": "1.3.4", "nystudio107/craft-cookies": "1.1.15", "putyourlightson/craft-sendgrid": "1.3.1", "studioespresso/craft-dumper": "2.0.0", "verbb/field-manager": "2.2.5", "verbb/formie": "1.6.36.1", "verbb/super-table": "2.7.5.1", "vlucas/phpdotenv": "^3.4.0"

i-just commented 8 months ago

Hi, thanks for reaching out! Any chance you could send your composer.json, composer.lock and database backup from before the upgrade to support@craftcms.com so that we can try to replicate this?

0xElectric commented 8 months ago

Removing this block of code from config/app.php fixed it for me:

'components' => [
  'log' => [
    'targets' => [
      '__craftSentryTarget' => function () {
        if (!class_exists('diginov\\sentry\\log\\SentryTarget')) {
          return null;
        }

        return Craft::createObject([
          'class' => 'diginov\\sentry\\log\\SentryTarget',
          'enabled' => CRAFT_ENVIRONMENT != 'dev',
          'anonymous' => false,
          'dsn' => App::env('SENTRY_DSN'),
          'release' => App::env('SENTRY_RELEASE'),
          'environment' => App::env('SENTRY_ENVIRONMENT'),
          'levels' => ['error', 'warning'],
          'exceptCodes' => [403, 404, 401],
          'exceptPatterns' => ['VolumeObjectNotFoundException'],
        ]);
      },
    ],
  ],
],

seems totally unrelated to the error at first glance

martinleveille commented 5 months ago

For future reference, the way to integrate Sentry Logger using the advanced method in app.php has changed since Craft 4. There is a warning in the changelog about that change. You can view the documentation here:

https://github.com/diginov/craft-sentry-logger/blob/main/README.md