timmyomahony / craft-matrix-field-preview

Configure a screenshot preview for all your matrix field blocks, giving your clients a better publishing experience.
https://plugins.craftcms.com/matrix-field-preview
Other
16 stars 4 forks source link

Error while updating to v3 #77

Closed mofman closed 2 years ago

mofman commented 2 years ago

Getting this error while updating to v3. Still on craft cms 3.7.44

Database Exception: SQLSTATE[HY000]: General error: 4161 Unknown data type: 'DROP'
The SQL being executed was: ALTER TABLE craft_matrixfieldpreview_blocktypes_config CHANGE categoryId categoryId DROP NOT NULL

Migration: weareferal\matrixfieldpreview\migrations\m220602_095344_add_category_foreignkey

Output:

> add column categoryId integer to table {{%matrixfieldpreview_blocktypes_config}} ... done (time: 0.237s)
> alter column categoryId in table {{%matrixfieldpreview_blocktypes_config}} to DROP NOT NULL ...Exception: SQLSTATE[HY000]: General error: 4161 Unknown data type: 'DROP'
The SQL being executed was: ALTER TABLE craft_matrixfieldpreview_blocktypes_config CHANGE categoryId categoryId DROP NOT NULL (/Users/user/Sites/website/vendor/yiisoft/yii2/db/Schema.php:676)
#0 /Users/user/Sites/website/vendor/yiisoft/yii2/db/Command.php(1320): yii\db\Schema->convertException(Object(PDOException), 'ALTER TABLE cr...')
#1 /Users/user/Sites/website/vendor/yiisoft/yii2/db/Command.php(1105): yii\db\Command->internalExecute('ALTER TABLE cr...')
#2 /Users/user/Sites/website/vendor/yiisoft/yii2/db/Migration.php(420): yii\db\Command->execute()
#3 /Users/user/Sites/website/vendor/weareferal/matrix-field-preview/src/migrations/m220602_095344_add_category_foreignkey.php(16): yii\db\Migration->alterColumn('{{%matrixfieldp...', 'categoryId', 'DROP NOT NULL')
#4 /Users/user/Sites/website/vendor/craftcms/cms/src/db/Migration.php(53): weareferal\matrixfieldpreview\migrations\m220602_095344_add_category_foreignkey->safeUp()
#5 /Users/user/Sites/website/vendor/craftcms/cms/src/db/MigrationManager.php(232): craft\db\Migration->up(true)
#6 /Users/user/Sites/website/vendor/craftcms/cms/src/db/MigrationManager.php(148): craft\db\MigrationManager->migrateUp(Object(weareferal\matrixfieldpreview\migrations\m220602_095344_add_category_foreignkey))
#7 /Users/user/Sites/website/vendor/craftcms/cms/src/services/Updates.php(250): craft\db\MigrationManager->up()
#8 /Users/user/Sites/website/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(532): craft\services\Updates->runMigrations(Array)
#9 /Users/user/Sites/website/vendor/craftcms/cms/src/controllers/UpdaterController.php(201): craft\controllers\BaseUpdaterController->runMigrations(Array, 'restore-db')
#10 [internal function]: craft\controllers\UpdaterController->actionMigrate()
#11 /Users/user/Sites/website/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 /Users/user/Sites/website/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#13 /Users/user/Sites/website/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('migrate', Array)
#14 /Users/user/Sites/website/vendor/craftcms/cms/src/web/Application.php(293): yii\base\Module->runAction('updater/migrate', Array)
#15 /Users/user/Sites/website/vendor/craftcms/cms/src/web/Application.php(690): craft\web\Application->runAction('updater/migrate')
#16 /Users/user/Sites/website/vendor/craftcms/cms/src/web/Application.php(250): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))
#17 /Users/user/Sites/website/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#18 /Users/user/Sites/website/public/index.php(12): yii\base\Application->run()
#19 /Users/user/.composer/vendor/laravel/valet/server.php(234): require('/Users/user/S...')
#20 {main}
timmyomahony commented 2 years ago

I haven't upgraded the plugin for Craft 4 yet so that shouldn't be the issue.

Looks like that issue is with one of the migrations I've included with the plugin. It's having an issue altering a column to accept "not null".

What database are you using? MySQL? Do you know what version? I'll have to have a look into it a bit more.

mofman commented 2 years ago

MariaDB 10.7.3 which is based on MySQL 5.5.5

Thanks for taking a look.

mofman commented 2 years ago

0841752 Fixed it for me Timmy. Thanks

timmyomahony commented 2 years ago

Yep, just working on cleaning up the migrations. I'll release fully as soon as I can test a bit more.

timmyomahony commented 2 years ago

Added improvements to the migrations to hopefully fix this issue https://github.com/weareferal/craft-matrix-field-preview/releases/tag/3.0.2