nystudio107 / craft-retour

Retour allows you to intelligently redirect legacy URLs, so that you don't lose SEO value when rebuilding & restructuring a website
https://nystudio107.com/plugins/retour
Other
38 stars 26 forks source link

Upgrading from 3.x to 4.x results in error #309

Closed boboldehampsink closed 4 months ago

boboldehampsink commented 4 months ago

Describe the bug

I am migrating a site from Craft 3 to Craft 4. It uses the latest 3.x version of Retour. When upgrading to 4.x I see the following error:

web-1  | *** applying m221130_224500_add_priorities_column
web-1  |     > add column priority integer NULL DEFAULT 5 to table {{%retour_static_redirects}} ...Exception: SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "retour_static_redirects" does not exist
web-1  | The SQL being executed was: ALTER TABLE "retour_static_redirects" ADD "priority" integer NULL DEFAULT 5 (/app/user/vendor/yiisoft/yii2/db/Schema.php:676)
web-1  | #0 /app/user/vendor/yiisoft/yii2/db/Command.php(1325): yii\db\Schema->convertException(Object(PDOException), 'ALTER TABLE "re...')
web-1  | #1 /app/user/vendor/yiisoft/yii2/db/Command.php(1120): yii\db\Command->internalExecute('ALTER TABLE "re...')
web-1  | #2 /app/user/vendor/yiisoft/yii2/db/Migration.php(388): yii\db\Command->execute()
web-1  | #3 /app/user/vendor/nystudio107/craft-retour/src/migrations/m221130_224500_add_priorities_column.php(19): yii\db\Migration->addColumn('{{%retour_stati...', 'priority', Object(yii\db\ColumnSchemaBuilder))
web-1  | #4 /app/user/vendor/craftcms/cms/src/db/Migration.php(50): nystudio107\retour\migrations\m221130_224500_add_priorities_column->safeUp()
web-1  | #5 /app/user/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
web-1  | #6 /app/user/vendor/craftcms/cms/src/console/controllers/MigrateController.php(361): yii\console\controllers\BaseMigrateController->migrateUp('m221130_224500_...')
web-1  | #7 [internal function]: craft\console\controllers\MigrateController->actionAll()
web-1  | #8 /app/user/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
web-1  | #9 /app/user/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
web-1  | #10 /app/user/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('all', Array)
web-1  | #11 /app/user/vendor/craftcms/cms/src/console/ControllerTrait.php(90): yii\console\Controller->runAction('all', Array)
web-1  | #12 /app/user/vendor/yiisoft/yii2/base/Module.php(552): craft\console\controllers\MigrateController->runAction('all', Array)
web-1  | #13 /app/user/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
web-1  | #14 /app/user/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction('migrate/all', Array)
web-1  | #15 /app/user/vendor/yiisoft/yii2/base/Controller.php(212): craft\console\Application->runAction('migrate/all', Array)
web-1  | #16 /app/user/vendor/craftcms/cms/src/console/Controller.php(207): yii\base\Controller->run('migrate/all', Array)
web-1  | #17 /app/user/vendor/craftcms/cms/src/console/controllers/UpController.php(64): craft\console\Controller->run('migrate/all', Array)
web-1  | #18 [internal function]: craft\console\controllers\UpController->actionIndex()
web-1  | #19 /app/user/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
web-1  | #20 /app/user/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
web-1  | #21 /app/user/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('', Array)
web-1  | #22 /app/user/vendor/craftcms/cms/src/console/ControllerTrait.php(90): yii\console\Controller->runAction('', Array)
web-1  | #23 /app/user/vendor/craftcms/cms/src/console/Controller.php(216): craft\console\Controller->traitRunAction('', Array)
web-1  | #24 /app/user/vendor/yiisoft/yii2/base/Module.php(552): craft\console\Controller->runAction('', Array)
web-1  | #25 /app/user/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('up', Array)
web-1  | #26 /app/user/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction('up', Array)
web-1  | #27 /app/user/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('up', Array)
web-1  | #28 /app/user/vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest(Object(craft\console\Request))
web-1  | #29 /app/user/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
web-1  | #30 /app/user/craft(20): yii\base\Application->run()
web-1  | #31 {main}
web-1  | *** failed to apply m221130_224500_add_priorities_column (time: 0.002s)

To reproduce

Steps to reproduce the behaviour:

  1. Install Craft 3
  2. Install Retour 33. Upgrade to Craft 4 with Retour 4

Expected behaviour

I expect it to has a migration that creates this table when upgrading

khalwat commented 4 months ago

The install migration for the Craft 3 version of Retour does create the table retour_static_redirects -> https://github.com/nystudio107/craft-retour/blob/v3/src/migrations/Install.php#L108

Are you for some reason not seeing that table in your install?

boboldehampsink commented 4 months ago

Yeah it's not there. Also when upping this project with existing project config, it's not created. I am using PostgreSQL.

khalwat commented 4 months ago

Well Project Config won't create db tables... if you uninstall and re-install Retour on the Craft 3 version of the site, is the table not created?

boboldehampsink commented 4 months ago

The table was not created. I ran again and now it is... weird. But guess I can close this issue then. THanks anyway!