elleracompany / craft-cookie-consent

GDPR-Compliant cookie consent banner for Craft CMS
Other
6 stars 5 forks source link

Error after update to 1.6.1 - migration could be applied #76

Closed nordentwickler closed 2 years ago

nordentwickler commented 2 years ago

Hello,

i just wanted to Upgrade from1.4.2 to 1.6.1 but there was an error on applying the migration:

Applying new migrations ... error: The command "'/usr/local/bin/php' '/app/craft' 'migrate/all' '--no-backup' '--no-content'" failed.

Exit Code: 1(General error)

Working directory: /app

Output:
================
Checking for pending Craft and plugin migrations ...
Total 1 new GDPR Cookie Consent migration to be applied:
    - m201126_101032_v1_5_0

*** applying m201126_101032_v1_5_0
    > alter column ip in table {{%cookie_consent_consent}} to string(39) NULL DEFAULT NULL ... done (time: 0.013s)
    > add column dateInvalidated datetime NOT NULL DEFAULT '2019-05-14 00:00:00' to table {{%cookie_consent_site_settings}} ...Exception: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'dateInvalidated'
The SQL being executed was: ALTER TABLE `cookie_consent_site_settings` ADD `dateInvalidated` datetime(0) NOT NULL DEFAULT '2019-05-14 00:00:00' (/app/vendor/yiisoft/yii2/db/Schema.php:676)
#0 /app/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema->convertException(Object(PDOException), 'ALTER TABLE `co...')
#1 /app/vendor/yiisoft/yii2/db/Command.php(1102): yii\db\Command->internalExecute('ALTER TABLE `co...')
#2 /app/vendor/yiisoft/yii2/db/Migration.php(377): yii\db\Command->execute()
#3 /app/vendor/elleracompany/craft-cookie-consent/src/migrations/m201126_101032_v1_5_0.php(26): yii\db\Migration->addColumn('{{%cookie_conse...', 'dateInvalidated', Object(craft\db\mysql\ColumnSchemaBuilder))
#4 /app/vendor/craftcms/cms/src/db/Migration.php(52): elleracompany\cookieconsent\migrations\m201126_101032_v1_5_0->safeUp()
#5 /app/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(758): craft\db\Migration->up()
#6 /app/vendor/craftcms/cms/src/console/controllers/MigrateController.php(385): yii\console\controllers\BaseMigrateController->migrateUp('m201126_101032_...')
#7 [internal function]: craft\console\controllers\MigrateController->actionAll()
#8 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#9 /app/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#10 /app/vendor/yiisoft/yii2/console/Controller.php(182): yii\base\Controller->runAction('all', Array)
#11 /app/vendor/yiisoft/yii2/base/Module.php(552): yii\console\Controller->runAction('all', Array)
#12 /app/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/all', Array)
#13 /app/vendor/craftcms/cms/src/console/Application.php(89): yii\console\Application->runAction('migrate/all', Array)
#14 /app/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('migrate/all', Array)
#15 /app/vendor/yiisoft/yii2/base/Application.php(384): yii\console\Application->handleRequest(Object(craft\console\Request))
#16 /app/craft(23): yii\base\Application->run()
#17 {main}
*** failed to apply m201126_101032_v1_5_0 (time: 0.036s)

0 from 1 migrations were applied.

Migration failed. The rest of the migrations are canceled.

Craft CMS 3.7.27, 7.4.23 and MySQL 8

jellingsen commented 2 years ago

Hi,

Column already exists: 1060 Duplicate column name 'dateInvalidated'

This is odd, the invalidation logic as implemented in v1.5 and you should not have this column already. Have you imported a the consents from another instance at some point? - if not, i need to investigate this further.

Anyway, there are a few ways you could try to solve this:

nordentwickler commented 2 years ago

Deleting the column dateInvalidated helped, to update without a problem! There was maybe an update before, which failed but didn't changed the database back. You can close this issue - thank u!

jellingsen commented 2 years ago

Great. Thank you for letting me know.