sebastian-lenz / craft-linkfield

Link field for Craft 3
MIT License
122 stars 66 forks source link

Failed Migration to V2 #174

Closed mattbloomfield closed 2 years ago

mattbloomfield commented 3 years ago

Not sure if it's helpful but here is the error I experienced. I was aware that there could be issues.

Database Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_elementItem' in 'field list'
The SQL being executed was: SELECT elementId, siteId, field_elementItem
FROM content

Migration: lenz\linkfield\migrations\m190417_202153_migrateDataToTable

Output:

> create table {{%lenz_linkfield}} ... done (time: 0.032s)
> create unique index idx_gxtjabxygoxmyrlhzkdstpdeunmpcbdvxpbd on {{%lenz_linkfield}} (elementId,siteId,fieldId) ... done (time: 0.015s)
> create index idx_yyobusidmyoblyyoxpymwskiyguastbjxhba on {{%lenz_linkfield}} (fieldId) ... done (time: 0.011s)
> create index idx_garersujxmcaoznzphagpvvmsxdwussrldbs on {{%lenz_linkfield}} (siteId) ... done (time: 0.010s)
> add foreign key fk_ajpqirmpraaeiweqvqcmzidkfkwrffkqyqdi: {{%lenz_linkfield}} (elementId) references {{%elements}} (id) ... done (time: 0.045s)
> add foreign key fk_riiylkvjszwhipoytbrehemocahkewnyukja: {{%lenz_linkfield}} (fieldId) references {{%fields}} (id) ... done (time: 0.029s)
> add foreign key fk_cellnycjifliqsdimofjcfujkagowunjzuow: {{%lenz_linkfield}} (linkedId) references {{%elements}} (id) ... done (time: 0.029s)
> add foreign key fk_spbetsmmokiqiqanlzsferurddqbjabpilkl: {{%lenz_linkfield}} (linkedSiteId) references {{%sites}} (id) ... done (time: 0.029s)
> update in {{%fields}} ... done (time: 0.007s)
> update in {{%fields}} ... done (time: 0.003s)
> update in {{%fields}} ... done (time: 0.003s)
> update in {{%fields}} ... done (time: 0.003s)
> update in {{%fields}} ... done (time: 0.003s)
> update in {{%fields}} ... done (time: 0.003s)
> batch insert into {{%lenz_linkfield}} ... done (time: 0.000s)
> drop column field_cardText_contentUrl from table {{%matrixcontent_cardtextmatrix}} ... done (time: 0.024s)
Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_elementItem' in 'field list'
The SQL being executed was: SELECT elementId, siteId, field_elementItem
FROM content (/var/www/vendor/yiisoft/yii2/db/Schema.php:678)
#0 /var/www/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema->convertException(Object(PDOException), 'SELECT element...')
#1 /var/www/vendor/yiisoft/yii2/db/Command.php(1168): yii\db\Command->internalExecute('SELECT element...')
#2 /var/www/vendor/yiisoft/yii2/db/Command.php(410): yii\db\Command->queryInternal('fetchAll', NULL)
#3 /var/www/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Command->queryAll()
#4 /var/www/vendor/craftcms/cms/src/db/Query.php(152): yii\db\Query->all(NULL)
#5 /var/www/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(129): craft\db\Query->all()
#6 /var/www/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(90): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->updateLinkField(Object(lenz\linkfield\fields\LinkField), '{{%content}}', '')
#7 /var/www/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(54): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->updateField(Object(lenz\linkfield\fields\LinkField), '{{%content}}')
#8 /var/www/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(31): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->updateAllFields()
#9 /var/www/vendor/craftcms/cms/src/db/Migration.php(52): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->safeUp()
#10 /var/www/vendor/craftcms/cms/src/db/MigrationManager.php(232): craft\db\Migration->up(true)
#11 /var/www/vendor/craftcms/cms/src/db/MigrationManager.php(148): craft\db\MigrationManager->migrateUp(Object(lenz\linkfield\migrations\m190417_202153_migrateDataToTable))
#12 /var/www/vendor/craftcms/cms/src/services/Updates.php(251): craft\db\MigrationManager->up()
#13 /var/www/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(509): craft\services\Updates->runMigrations(Array)
#14 /var/www/vendor/craftcms/cms/src/controllers/UpdaterController.php(203): craft\controllers\BaseUpdaterController->runMigrations(Array, 'restore-db')
#15 [internal function]: craft\controllers\UpdaterController->actionMigrate()
#16 /var/www/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#17 /var/www/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#18 /var/www/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('migrate', Array)
#19 /var/www/vendor/yiisoft/yii2/base/Module.php(534): craft\web\Controller->runAction('migrate', Array)
#20 /var/www/vendor/craftcms/cms/src/web/Application.php(277): yii\base\Module->runAction('updater/migrate', Array)
#21 /var/www/vendor/craftcms/cms/src/web/Application.php(674): craft\web\Application->runAction('updater/migrate')
#22 /var/www/vendor/craftcms/cms/src/web/Application.php(234): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))
#23 /var/www/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#24 /var/www/web/index.php(22): yii\base\Application->run()
#25 {main}

Plugin Versions

        "carlcs/craft-diywidget": "2.1.0",
        "carlcs/craft-redactorcustomstyles": "3.0.4",
        "craftcms/aws-s3": "1.2.15",
        "craftcms/cms": "3.7.13",
        "craftcms/feed-me": "4.4.0",
        "craftcms/mailgun": "1.4.3",
        "craftcms/redactor": "2.8.8",
        "dolphiq/redirect": "1.1.1",
        "jalendport/craft-readtime": "1.6.0",
        "misterbk/mix": "1.5.2",
        "mmikkel/cp-clearcache": "1.1.0",
        "mmikkel/cp-field-inspect": "1.2.5",
        "nystudio107/craft-retour": "3.1.61",
        "ostark/upper": "1.8.0",
        "ournameismud/fractal": "^1.0",
        "sebastianlenz/linkfield": "^2.0.0-beta.12",
        "solspace/craft-freeform": "3.11.11.1",
        "spacecatninja/imager-x": "v3.5.2",
        "spicyweb/craft-neo": "2.11.13",
        "topshelfcraft/environment-label": "3.2.0",
        "topshelfcraft/supersort": "3.1.0",
        "topshelfcraft/wordsmith": "3.3.0.1",
        "ueberdosis/html-to-prosemirror": "1.5.0",
        "vaersaagod/seomate": "1.1.11",
        "venveo/craft-bulkedit": "2.0.6",
        "verbb/cp-nav": "3.0.17",
        "verbb/default-dashboard": "1.0.8",
        "verbb/expanded-singles": "1.1.4",
        "verbb/field-manager": "2.2.4",
        "verbb/navigation": "1.4.21",
        "verbb/super-table": "2.6.8",
        "verbb/vizy": "1.0.7",
        "vlucas/phpdotenv": "^3.4.0",
        "yiisoft/yii2-redis": "^2.0"
mattbloomfield commented 3 years ago

After updating to 2.0.0-rc.1 I get this error:

Database Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_elementItem' in 'field list'
The SQL being executed was: SELECT elementId, siteId, field_elementItem
FROM content

Migration: lenz\linkfield\migrations\m190417_202153_migrateDataToTable

Output:

> update in {{%fields}} ... done (time: 0.008s)
> update in {{%fields}} ... done (time: 0.002s)
> update in {{%fields}} ... done (time: 0.002s)
> update in {{%fields}} ... done (time: 0.002s)
> update in {{%fields}} ... done (time: 0.002s)
> update in {{%fields}} ... done (time: 0.002s)
> batch insert into {{%lenz_linkfield}} ... done (time: 0.000s)
> drop column field_cardText_contentUrl from table {{%matrixcontent_cardtextmatrix}} ... done (time: 0.028s)
Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_elementItem' in 'field list'
The SQL being executed was: SELECT elementId, siteId, field_elementItem
FROM content (/var/www/vendor/yiisoft/yii2/db/Schema.php:678)
#0 /var/www/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema->convertException(Object(PDOException), 'SELECT element...')
#1 /var/www/vendor/yiisoft/yii2/db/Command.php(1168): yii\db\Command->internalExecute('SELECT element...')
#2 /var/www/vendor/yiisoft/yii2/db/Command.php(410): yii\db\Command->queryInternal('fetchAll', NULL)
#3 /var/www/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Command->queryAll()
#4 /var/www/vendor/craftcms/cms/src/db/Query.php(152): yii\db\Query->all(NULL)
#5 /var/www/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(129): craft\db\Query->all()
#6 /var/www/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(90): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->updateLinkField(Object(lenz\linkfield\fields\LinkField), '{{%content}}', '')
#7 /var/www/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(54): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->updateField(Object(lenz\linkfield\fields\LinkField), '{{%content}}')
#8 /var/www/vendor/sebastianlenz/linkfield/src/migrations/m190417_202153_migrateDataToTable.php(31): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->updateAllFields()
#9 /var/www/vendor/craftcms/cms/src/db/Migration.php(52): lenz\linkfield\migrations\m190417_202153_migrateDataToTable->safeUp()
#10 /var/www/vendor/craftcms/cms/src/db/MigrationManager.php(232): craft\db\Migration->up(true)
#11 /var/www/vendor/craftcms/cms/src/db/MigrationManager.php(148): craft\db\MigrationManager->migrateUp(Object(lenz\linkfield\migrations\m190417_202153_migrateDataToTable))
#12 /var/www/vendor/craftcms/cms/src/services/Updates.php(251): craft\db\MigrationManager->up()
#13 /var/www/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(509): craft\services\Updates->runMigrations(Array)
#14 /var/www/vendor/craftcms/cms/src/controllers/UpdaterController.php(203): craft\controllers\BaseUpdaterController->runMigrations(Array, 'restore-db')
#15 [internal function]: craft\controllers\UpdaterController->actionMigrate()
#16 /var/www/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#17 /var/www/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#18 /var/www/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('migrate', Array)
#19 /var/www/vendor/yiisoft/yii2/base/Module.php(534): craft\web\Controller->runAction('migrate', Array)
#20 /var/www/vendor/craftcms/cms/src/web/Application.php(277): yii\base\Module->runAction('updater/migrate', Array)
#21 /var/www/vendor/craftcms/cms/src/web/Application.php(674): craft\web\Application->runAction('updater/migrate')
#22 /var/www/vendor/craftcms/cms/src/web/Application.php(234): craft\web\Application->_processUpdateLogic(Object(craft\web\Request))
#23 /var/www/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#24 /var/www/web/index.php(22): yii\base\Application->run()
#25 {main}
kristoffeys commented 2 years ago

see https://github.com/sebastian-lenz/craft-linkfield/issues/164

Mosnar commented 2 years ago

@sebastian-lenz Just wanted to leave a note that I just tried the migration on a fairly complex site (Neo, SuperTable, Matrix, etc) and it worked flawlessly. :)